Skip to content

fix(tools): mid-turn steer releases a blocking process_manage wait (port kimi-code#3697) - #107858

Merged
teknium1 merged 1 commit into
mainfrom
kimi-code-port/steer-releases-process-wait
Sep 13, 2026
Merged

teknium1 merged 1 commit into
mainfrom
kimi-code-port/steer-releases-process-wait

Conversation

@teknium1

Copy link
Copy Markdown
Collaborator

A user message sent while the model sits in process_manage(action='wait') no longer waits out the full wait window — the wait releases in under a second, the process keeps running, and the model answers the user.

Symptom

Mid-turn user messages (CLI busy_input_mode=interrupt, gateway priority redirect, ACP redirect) route through AIAgent.redirect(), which during tool execution degrades to steer() + request_yield() on the tool worker threads. The local terminal backend's foreground wait honours that yield (4632923 adopts the live process into the background registry), but ProcessRegistry.wait() — the process_manage(action='wait') path used to watch an already-background process (CI watchers, builds, servers) — never checked it. The steer text rides the tool result, so the user's message was parked until the wait timed out: up to 180s by default, more with a raised TERMINAL_TIMEOUT.

Change

  • ProcessRegistry.wait() consumes a pending yield on its own thread each poll pass (the same 1s-granularity loop that already checks interrupt) and returns status="interrupted" with process_running: true plus a note telling the model the process is untouched, still notify-tracked, and that it should respond to the user now.
  • Plain interrupt, exit, and timeout paths unchanged. consume_yield clears the bit, so subsequent waits behave normally.

Port of MoonshotAI/kimi-code#3697 ("let steer interrupt background task waits" — their WaitFor tool had the same shape: steer added input for the next step but the active wait ran to its 600s cap), adapted to Hermes' per-thread yield mechanism.

Live repro

origin/main this branch
request_yield(waiter_tid) against a thread blocked in wait(timeout=12) no effect — wait ran the full 12s to timeout releases in 0.5s, status=interrupted, process_running=true, process alive

Reproduced and confirmed via real ProcessRegistry.adopt_local + sleep 30 subprocess with fresh imports against a temp HERMES_HOME (positive and negative: a wait with no yield still times out normally).

Validation

  • New TestWaitYieldRelease (2 invariant tests): yield releases the wait, keeps the process running, and clears the yield bit; a wait without a yield still times out.
  • tests/tools/test_process_wait_clarity.py + tests/tools/test_process_registry.py: 105 passed, 0 failed.
  • ruff check clean; Windows-footgun scan clean; compat-pointer check clean.

Infographic

infographic

@github-actions

github-actions Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

૮ >ﻌ< ა ci review

ran on 414e7b9 — fix(tools): steer/redirect releases a blocking process_manag

⚠️ Warnings

OSV vulnerability scan · View job

76 known vulnerabilities found in pinned dependencies.

How to fix:

Review the findings in the Security tab. Update the affected dependencies if a patched version is available.


debug info

CI timings

CI timings · View report · View job

Wall time 4m50s vs 4m50s (+0.0%). 5 job(s) slower, 8 faster, 1 unchanged.

  • Python lints / Windows footguns (blocking): -6.0s
  • Check contributors / check-attribution: +6.0s
  • OS-specific tests / macOS-only tests: -5.0s
  • Python tests / e2e: -2.0s
  • OSV scan / Scan lockfiles / osv-scan: -2.0s

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/tools Tool registry, model_tools, toolsets tool/terminal Terminal execution and process management labels Sep 11, 2026
@teknium1

Copy link
Copy Markdown
Collaborator Author

CI note: the Python tests failure on this PR is a pre-existing main-branch breakage (tests/hermes_cli/test_anon_auth_core.py — fixture resets the token memo to None after 173105c made it a dict; plus tests/hermes_cli/test_banner_git_state.py making live GitHub API calls that rate-limit on CI). Both are fixed in #107866. This PR's own suites (tests/tools/test_process_wait_clarity.py, test_process_registry.py) are green: 105 passed, 0 failed. Will rerun once #107866 lands.

@teknium1 teknium1 closed this Sep 13, 2026
@teknium1
teknium1 force-pushed the kimi-code-port/steer-releases-process-wait branch from f28d328 to 205645e Compare September 13, 2026 02:33
…ort of MoonshotAI/kimi-code#3697)

A user message sent mid-turn (CLI busy_input_mode=interrupt, gateway priority
redirect, ACP redirect) goes through AIAgent.redirect(), which during tool
execution degrades to steer() + request_yield() on the tool worker threads.
The local terminal backend's foreground wait honours the yield (adopting the
process into the background registry), but ProcessRegistry.wait() — the
process_manage(action='wait') path — never checked it: a model sitting in a
wait on an already-background process parked the user's message for up to the
full wait window (default 180s, clamp allows more).

wait() now consumes a pending yield on its own thread each poll pass and
returns status "interrupted" with process_running=true and a note telling the
model to respond to the user; the process is untouched and still
notify-tracked. The plain-interrupt and timeout paths are unchanged.

Live repro: on origin/main, request_yield() against a thread blocked in
wait(timeout=12) had no effect (wait ran to timeout); after this change the
wait releases in <1s with status=interrupted, process still running.

Port of MoonshotAI/kimi-code#3697 ("let steer interrupt background task
waits") adapted to Hermes' per-thread yield mechanism from 4632923.
@teknium1 teknium1 reopened this Sep 13, 2026
@teknium1
teknium1 merged commit cbd4492 into main Sep 13, 2026
37 checks passed
@teknium1
teknium1 deleted the kimi-code-port/steer-releases-process-wait branch September 13, 2026 04:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/tools Tool registry, model_tools, toolsets P2 Medium — degraded but workaround exists tool/terminal Terminal execution and process management type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants