Skip to content

fix(orchestrator): Safely admit execution after uncertain selection - #11

Closed
mwolson wants to merge 1 commit into
contrib/main/new-thread-model-priorityfrom
contrib/ctm/execution-selection-admission
Closed

mwolson wants to merge 1 commit into
contrib/main/new-thread-model-priorityfrom
contrib/ctm/execution-selection-admission

Conversation

@mwolson

@mwolson mwolson commented Sep 27, 2026 •

Copy link
Copy Markdown
Owner

Problem

When a provider start or a model change fails partway, T3 Code keeps trusting the selection it asked for, even though the provider may never have applied it. The thread's next turn can then run on the wrong model. A later selection change can replace a provider process that still holds output for the thread, so a finished background result is lost or labeled with a selection that did not produce it. A model change steered into a running Claude turn also leaves later wake-ups labeled with the old model.

Change

T3 Code now records, per provider binding, the selection the last acknowledged start actually ran. A failed or interrupted start invalidates that record, and only a trustworthy acknowledgment restores it. Selection changes, message dispatch and queued starts are planned from that record instead of from the thread's requested selection. After a start that failed partway, the next message opens a fresh session for the thread without resending the failed prompt, and other threads on the same provider process keep running.

A change that would replace a binding still holding undelivered output is refused with the existing "deliver it first" message, and a drain is offered, even when the selection that produced the output is unknown. A provider wake is never refused: it reuses its binding and its run is labeled with the selection that produced the buffered output when that is known. When a queued message is refused for undelivered output and a provider wake is already queued behind it, the wake runs first and the message keeps its place, then starts by itself once the wake ends.

Provider details that follow from the same rule:

  • Claude: a complete wake buffered by a process that has since exited is delivered by replaying it, without starting a new process. A successful live model change during a turn updates the recorded selection, so later wakes carry the new model.
  • ACP agents (including Grok): the next turn after an uncertain change re-sends the full selection. A configuration write whose outcome is unknown clears the recorded model, and output buffered with no known producing selection drains with whichever wake reaches it.
  • OpenCode 2 and Muse report their held wake-ups as undelivered output, so those continuation turns are admitted.

Upstream now provides several parts this layer used to carry: the Claude boot deadline (pingdotgg#30166 claude-mcp-deadline-after-boot), ignoring Claude's model-switch echo (pingdotgg#34498 claude-set-model-echo), retiring refused wake offers (pingdotgg#28173 failed-claude-wake-dispatch), and the busy and background-work guards on selection changes (pingdotgg#22755 preserve-active-turns-on-switch, pingdotgg#35029 setting-change-keeps-background-work), which still run after this planning, unchanged.

Scope

Bug fix: later turns can run on a model the provider never acknowledged, and buffered output can be lost or mislabeled. No upstream issue describes the whole admission defect yet. Open neighbours cover parts of it: pingdotgg#36397 busy-session-handoff and issue pingdotgg#32296 busy-session-handoff-refusal for busy-session handoff, and pingdotgg#23082 runtime-mode-change-keeps-turn for a mode change. The layer is large (21 files); if offered upstream it would split into execution evidence with switch planning, buffered-output ownership and drains, and ACP forced reconfiguration.

Verification

Run on zbook26 under Node 26.13.1. Focused tests at the layer pass: 1,036 server tests across selection restart, OpenCode 2 integration, the Claude and ACP adapters, control reads, the session manager, the switch service and turn start, plus the provider-core, provider-acp, provider-grok and provider-muse packages. provider-opencode shows two driver.test.ts failures that fail the same way on the bare upstream base. The whole orchestration-v2 test directory also passes.

With the layer's production files restored to upstream, 11 tests fail, including "plans a selection change from the selection that last ran, not a steered one", "opens a fresh session after a start that failed partway, without resending it", the idle, queued and queued-wake rows of "drains output before changing selection", "refuses a selection change while a rollback-attached binding holds a follow-up", "re-sends the model on the turn after a live selection change fails", "applies a model change sent with a steer to the running turn", "buffers wake output and requests a single continuation run" and "keeps a buffered continuation current when a user turn starts before dispatch".

No live provider was driven. The Claude, ACP, Grok, Muse, OpenCode and queue changes are covered by harness and replay tests only.

Known Limitations

  • OpenCode 2: if the thread's access mode or interaction mode is changed while a session
    stays open, a wake for output produced before the change fails to start with "Provider output
    must be delivered first", and later wakes fail the same way.
  • OpenCode 1: a start that is aborted before its prompt is sent is still recorded as having
    applied its model, so a later wake can be labeled with that model. No user turn runs on the
    wrong model, because each OpenCode 1 prompt carries its own model.
  • Claude without MCP: a Claude session opened with no T3 MCP server has no boot deadline and
    does not wait for the CLI to acknowledge initialization. Sessions with MCP, the normal case, get
    upstream's five-minute deadline.
  • A queued message whose start is refused for undelivered output, with no wake queued behind it,
    still fails with that message and the rest of the queue is held, as after any failed start. The
    output is delivered by the drain that is offered; the user sends the message again.
  • Claude: a wake buffered by a process that has exited is delivered without a new process only
    when it is whole: the root's result is buffered, and nothing follows it except session-task
    lifecycle turns that also ended. A partial wake, or one followed by a turn that started and did
    not end, still needs a new process, and if that cannot start upstream retires the wake and drops
    its frames.
  • Claude: a subagent that such a replayed wake started or resumed is shown as failed, since its
    process is gone, unless the buffer also holds its outcome.
  • Claude: after a live selection update fails, output the process buffers has no known producing
    selection. Its wake is labeled with the session manager's last acknowledged selection, or the
    thread's selection, as for ACP. A wake buffer that already existed when the update failed loses
    its label as soon as another frame joins it.
  • ACP: after a configuration write whose outcome is unknown, the session's producing selection
    stays unknown until a later model write succeeds. Wakes in that state are labeled with the
    session manager's last acknowledged selection, or the thread's selection. A session kept on
    default or auto never re-establishes it.
  • No live provider was driven; the Claude, ACP and queue changes are covered by harness tests only.

@mwolson
mwolson added this pull request to stack #36 September 27, 2026 21:48
@mwolson
mwolson force-pushed the contrib/ctm/compatible-active-steering branch from 99e5bfe to 9819940 Compare October 1, 2026 12:38
@mwolson
mwolson force-pushed the contrib/ctm/execution-selection-admission branch from 189b969 to 32c37ae Compare October 1, 2026 12:38
@mwolson
mwolson removed this pull request from stack #36 October 1, 2026 12:39
@mwolson
mwolson added this pull request to stack #53 October 1, 2026 12:41
@mwolson
mwolson force-pushed the contrib/ctm/compatible-active-steering branch from 9819940 to adf7c52 Compare October 1, 2026 14:13
@mwolson
mwolson force-pushed the contrib/ctm/execution-selection-admission branch from 32c37ae to a2bd3cf Compare October 1, 2026 14:13
@mwolson
mwolson removed this pull request from stack #53 October 1, 2026 14:13
@mwolson
mwolson added this pull request to stack #55 October 1, 2026 14:13
@mwolson
mwolson force-pushed the contrib/ctm/compatible-active-steering branch from adf7c52 to 70793a4 Compare October 3, 2026 20:27
@mwolson
mwolson force-pushed the contrib/ctm/execution-selection-admission branch from a2bd3cf to 77bc6cf Compare October 3, 2026 20:27
@mwolson
mwolson removed this pull request from stack #55 October 3, 2026 20:28
@mwolson
mwolson added this pull request to stack #57 October 3, 2026 20:28
@mwolson
mwolson force-pushed the contrib/ctm/execution-selection-admission branch from 77bc6cf to aa97afa Compare October 4, 2026 03:12
@mwolson
mwolson removed this pull request from stack #57 October 4, 2026 03:12
@mwolson
mwolson added this pull request to stack #60 October 4, 2026 03:13
@mwolson
mwolson removed this pull request from stack #60 October 4, 2026 15:12
@mwolson
mwolson added this pull request to stack #62 October 4, 2026 15:12
@mwolson
mwolson removed this pull request from stack #62 October 4, 2026 19:29
@mwolson
mwolson added this pull request to stack #64 October 4, 2026 19:30
@mwolson
mwolson force-pushed the contrib/ctm/execution-selection-admission branch from aa97afa to f5e7184 Compare October 6, 2026 17:48
@mwolson
mwolson removed this pull request from stack #64 October 6, 2026 17:49
@mwolson
mwolson added this pull request to stack #68 October 6, 2026 17:50
@mwolson
mwolson removed this pull request from stack #68 October 6, 2026 19:18
@mwolson
mwolson added this pull request to stack #70 October 6, 2026 19:19
@mwolson
mwolson removed this pull request from stack #70 October 6, 2026 21:12
@mwolson
mwolson added this pull request to stack #72 October 6, 2026 21:13
@mwolson
mwolson removed this pull request from stack #72 October 6, 2026 22:10
@mwolson
mwolson added this pull request to stack #74 October 6, 2026 22:10
@mwolson
mwolson changed the base branch from contrib/ctm/compatible-active-steering to contrib/main/provider-log-thread-files October 17, 2026 14:24
@mwolson
mwolson force-pushed the contrib/main/provider-log-thread-files branch from 40991f8 to dcb7888 Compare October 17, 2026 14:24
@mwolson
mwolson force-pushed the contrib/ctm/execution-selection-admission branch from 66a48ef to ce865e4 Compare October 17, 2026 14:24
@mwolson
mwolson added this pull request to stack #90 October 17, 2026 14:25
@mwolson
mwolson removed this pull request from stack #90 October 17, 2026 17:28
@mwolson
mwolson added this pull request to stack #92 October 17, 2026 17:29
@mwolson
mwolson removed this pull request from stack #92 October 17, 2026 23:04
@mwolson
mwolson added this pull request to stack #96 October 17, 2026 23:05
@mwolson
mwolson force-pushed the contrib/main/provider-log-thread-files branch from dcb7888 to 1ce492e Compare October 22, 2026 03:11
@mwolson
mwolson force-pushed the contrib/ctm/execution-selection-admission branch from ce865e4 to 1386bac Compare October 22, 2026 03:11
@mwolson
mwolson removed this pull request from stack #96 October 22, 2026 04:53
@mwolson
mwolson added this pull request to stack #99 October 22, 2026 04:54
@mwolson
mwolson force-pushed the contrib/ctm/execution-selection-admission branch 2 times, most recently from 652fa48 to fcd19df Compare October 24, 2026 00:11
@mwolson
mwolson removed this pull request from stack #99 October 24, 2026 01:36
@mwolson
mwolson added this pull request to stack #101 October 24, 2026 01:36
@mwolson
mwolson force-pushed the contrib/main/provider-log-thread-files branch from 611c9b9 to 886f88f Compare October 24, 2026 16:10
@mwolson
mwolson force-pushed the contrib/ctm/execution-selection-admission branch from fcd19df to 878cfc8 Compare October 24, 2026 16:10
@mwolson
mwolson removed this pull request from stack #101 October 24, 2026 19:49
@mwolson
mwolson added this pull request to stack #103 October 24, 2026 19:50
@mwolson
mwolson removed this pull request from stack #103 October 29, 2026 11:33
@mwolson
mwolson force-pushed the contrib/main/provider-log-thread-files branch from 886f88f to f5a736f Compare October 29, 2026 11:33
@mwolson
mwolson force-pushed the contrib/ctm/execution-selection-admission branch from 878cfc8 to 01e8ce1 Compare October 29, 2026 11:33
@mwolson
mwolson added this pull request to stack #104 October 29, 2026 11:34
@mwolson
mwolson removed this pull request from stack #104 October 30, 2026 00:23
@mwolson
mwolson added this pull request to stack #106 October 30, 2026 00:24
@mwolson
mwolson removed this pull request from stack #106 October 30, 2026 18:14
@mwolson

mwolson commented Nov 15, 2026

Copy link
Copy Markdown
Owner Author

Dropped from the stack on 2026-11-15: its assertions fail on current upstream (b732621), but no real Claude, Codex or ACP session reached any of the states, so the bug was not reproduced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant