Skip to content

fix(tui): rebuild the agent for every MCP tool-set change - #1494

Merged
corbits-triage[bot] merged 7 commits into
mainfrom
cl-10782-make-the-mcp-tool-reload-safe-and-complete-instead-of
Oct 17, 2026
Merged

corbits-triage[bot] merged 7 commits into
mainfrom
cl-10782-make-the-mcp-tool-reload-safe-and-complete-instead-of

Conversation

@bwachman

Copy link
Copy Markdown
Contributor

Summary

  • In the TUI, a change to the MCP tool set (connect, /mcp add, retry, enable, disable, remove) reaches the reactor only through an agent rebuild. Nothing mutates a live agent's tools anymore. Interchange fixes an agent's tool set at build, so this lets authz see every tool the agent can call.
  • The rebuild waits for the reactor's open message run to end (from fix(tui): defer agent reload until the reactor's message run ends #1486). It also waits when an approval rehydrated from disk resumes with no run open, by treating a message.correlated with no open run as busy until the reply, run end, fatal error or done.
  • Tools that connect after the current build stay off the model's wire and out of tool_search until the rebuild. A call to one gets an actionable "becomes callable once this turn ends" denial instead of the authz wiring-defect error. A non-read-only MCP tool added after startup now gets an approval prompt and runs once approved.
  • A same-session rebuild keeps the director's task list. Every agent build logs its reason (initial, mcp-tools-changed, interrupt, session-rotation) and the tool names it added, removed or changed.
  • No changes under vendor/. corbits exec still adds late MCP tools to a live agent and keeps the live-dispatch Map workaround; its comment now names that caller.

Stacked on #1486; review that first. The diff against its branch is this change only.

Verification

  • bun run check and bun run test pass (9211 tests)
  • New tests fail on the base branch and pass here:
    • non-yolo e2e: an MCP tool mounted after agent build is not searchable or callable before the rebuild, then after it asks, is approved, and runs once
    • runner tests: a mid-run connect rebuilds once after the run ends, with its reason logged; a retry while idle rebuilds; a resumed rehydrated approval defers the rebuild until its reply; a rebuild with nothing new is skipped
    • the task list survives a same-session rebuild

Fixes CL-10782
Refs CL-10777
Part of CL-10763

The reactor authorizes against the tool definitions it snapshotted at
build. A tool mounted later was still found by tool_search and could
reach the wire, but an ask on it had no definition to build an approval
prompt from and failed as a wiring defect. The TUI now pins the tool
set at each build: search, the advertised wire, and authorization only
see pinned tools, a late hit tells the model it becomes callable next
turn, and a rebuild with nothing new to pin is skipped.
@linear-code

linear-code Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

CL-10782

CL-10763

CL-10777

@corbits-triage

corbits-triage Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Triage: Pass

No changes needed from you. A maintainer will review this pull request.

@TheGreatAxios TheGreatAxios left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review · Approve

The TUI rebuilds the agent on every MCP tool-set change and keeps tools mounted after the current build off the wire, search, and authz until that rebuild.

Findings

No findings.

@TheGreatAxios TheGreatAxios left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review · Comment

Planner: approach holds. A TUI tool-set change reaches the reactor only through an idle rebuild, including while a rehydrated approval has no open run. Search, the advertised wire, and authorize see the pinned set; a late call is denied before the gate. The task list and sticky compact instructions carry across a same-session rebuild. Exec still uses live dispatch and does not clear the TUI pin.

Findings

No findings.

A rebuild must clear the rehydrated-approval hold, or the next idle
check still treats the session as resuming. Interrupt and session
rotation also clear a deferred reload before buildAgent awaits, so a
connect during that build can still set the flag. Initial and
mcp-tools-changed builds leave pendingReload for reloadIfIdle.
@TheGreatAxios
TheGreatAxios changed the base branch from cl-10766-dont-reload-the-agent-while-an-approval-resumed-run-is-still to main October 17, 2026 05:56
@corbits-triage
corbits-triage Bot merged commit d5750ae into main Oct 17, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants