Skip to content

refactor(delegation): offer Delegation on every supported turn without a per-turn flag - #2280

Merged
chuks-qua merged 2 commits into
mainfrom
feat/implement-issue-2218
Oct 23, 2026
Merged

chuks-qua merged 2 commits into
mainfrom
feat/implement-issue-2218

Conversation

@chuks-qua

@chuks-qua chuks-qua commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

What

Before this PR, #2271 had already removed the wording check from the server: every turn on a provider that supports Delegation gets the Delegation lease, and the mcode instructions tell the model when to use delegate_task instead of a native sub-agent or thread_launch. One gate was left behind. The server still sent a per-turn threadControlEligible flag, and the Codex adapter used it to skip the mcode attach (or restart a pooled session) when the flag changed.

This PR removes that flag. Codex now attaches the Delegation toolkit on every session, like the other adapters. The Coordinator wake check reads the lease the turn actually holds (holdsDelegationLease) instead of the removed flag.

 TurnRequest
-  threadControlEligible?: boolean

 CodexProvider.attachCodexMcode
-  if no Browser grant and not eligible: return
-  attach({ threadControl: eligible })
+  attach({ threadControl: true })

 CodexProvider.reconcileCodexSession
-  if eligibility changed: restartCodexSessionForThreadControl()

 coordinator-wake-service
-  if !turn.threadControlEligible: skip
+  if !turn.holdsDelegationLease: skip

The runtime-mode ceiling from ADR-0032 already holds on main: a delegated thread inherits the Coordinator's mode and cannot ask for a broader one.

Verification:

  • packages/providers: full suite, 112 files and 1700 tests passed.
  • apps/server: the mcode-mcp, thread-control and agents/steering suites, plus turn-steer-delivery and agent-service-gate, ran 39 files and 496 tests, all passed.
  • Typecheck is clean for contracts, providers and server. bun run lint shows only existing warnings in unrelated scripts.

Codex test change:

  • Before: "attaches for Browser alone when the turn is not thread-control eligible" expected threadControl: false.
  • After: "attaches the Delegation toolkit whatever the user's wording, without a Browser grant" sends "Farm this out to Claude" and expects attach to be called with threadControl: true.

Closes #2218

Why

Delegation should be offered whenever the provider supports it, and the user should not have to phrase a request a certain way to get it. The runtime-mode ceiling is the safety bound, not wording. The leftover flag kept a second, Codex-only gate alive. It also cost a session restart whenever eligibility changed.

Review Notes

  • Mode step-down not built. ADR-0032 says an inherited mode steps down to the broadest one the target provider offers. Today there are only two modes, full and supervised, and every provider supports both, so the rule never changes the outcome. I left it out rather than add code that does nothing.
  • Follow-up. ProviderMcodeAttachRequest.threadControl is now always true. Removing the field touches McodeSession and the MCP tool listing, so it belongs in its own PR. I updated its docstring for now.
  • No UI, config, migration or docs changes. ADR-0032 already describes the target behavior.

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

TurnRequest.threadControlEligible was the last piece of the wording
gate. Since #2271 the server set it from the provider alone, so it
never varied for a Codex session, but the Codex adapter still used it
to decide whether to attach the Delegation toolkit and kept a session
restart for an eligibility change that could no longer happen.

Codex now attaches the Delegation toolkit to every session, as the
Claude, Cursor and Copilot adapters already do. The steer runtime
reads whether a turn holds the Delegation lease from the lease
directive itself instead of the request flag.

Part of #2218
@chuks-qua
chuks-qua merged commit fd71c7a into main Oct 23, 2026
20 of 22 checks passed
@chuks-qua
chuks-qua deleted the feat/implement-issue-2218 branch October 23, 2026 11:24
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.

feat: offer Delegation without the wording gate, bounded by a runtime-mode ceiling

1 participant