feat(agent): publish MCP discovery phase and agent run id - #29450
ibetitsmike wants to merge 1 commit into
Conversation
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Bravo. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
9048755 to
6520ca9
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. Hooray! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
6520ca9 to
d9249ea
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
d9249ea to
b1af1ff
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
b1af1ff to
baed687
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
baed687 to
1485469
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. 🎉 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
1485469 to
cf184f4
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
cf184f4 to
1e1da6f
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. Keep them coming! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Stack context
This stack replaces #29114 after review feedback that a single
mcp_settledbool was underdeveloped and the change too large to review. It defines how workspace MCP discovery is communicated from the agent to chats: the agent publishes one discovery report inside the existing context snapshot (PushContextState), coderd persists it atomically with the resources, and chatd,find_tools, the create/start workspace tools, and the chat context UI all consume that same committed report.The report has three parts. Completeness:
MCPDiscovery.phaseisPENDINGuntil the agent's initial MCP reload has finished (success, failure, or zero servers all count) andCOMPLETEafterwards for the rest of the process; later reloads update outcomes but never move it back. Per-source outcomes stay on the existingContextResourcerows:mcp_configrows carry structural and semantic config errors,mcp_serverrows carry discovered servers (including zero tools), failed servers with a sanitized error, and a retained previous connection as OK plus a warning. Freshness: every snapshot carries theagent_run_idof the process that produced it, and the agent reports the same id inStartup, so a snapshot is known to describe the current process when the two ids match. Timestamps are deliberately not used for freshness becauseready_atis agent clock andreceived_atis coderd clock.Discovery completeness, per-source outcomes, turn eligibility, and the result of an actual tool invocation stay separate facts. Out of scope: continuous health monitoring, reconnect detection, automatic retries, and any retry or reload UI.
Layers, bottom to top: #29448 agent diagnostics, #29449 protocol and persistence, #29450 agent publication, #29451 chat projection, #29452 first-turn gate, #29453 context UI. Each layer builds and passes its tests on its own. The composed stack was validated end to end with remote UAT; the record is on #29453.
Why
#29449 gives the protocol a discovery phase and a per-process run id; this layer makes the agent fill them in.
Fix
The agent generates
agentRunIDonce inagent.New, sends it inUpdateStartup, and passes it toagentcontext, which stamps it on every push.agentmcp.Manager.Report()gains the discovery phase (pending until the first reload body reaches a terminal result, then complete), and settlement firesonChangeonce even when the catalog is unchanged so a zero-server workspace still publishes a complete report.agentcontext.Managersamples the MCP report once, beforeResolveContext, in bothresolveAndBroadcastandResync, and uses that single sample for the server rows, the config overlays, and the snapshot's phase. A phase captured before resolution can never label a pre-settlement catalog as complete, which closes the race a review of #29114 pointed out.Testing
Tests cover phase capture before the catalog (channel-synchronized, no sleeps), the
Resyncpath, zero-server settlement publishing a complete snapshot with unchanged resources, the drpc conversion of run id and phase, and the agent sending the same non-empty run id inStartupand in its first push. Remote UAT of the composed stack is recorded on #29453.Review record
90487555c2: no findings (Codex Review: Didn't find any major issues).6520ca9595: no findings on6520ca9595.d9249ea1cd: no findings ond9249ea1cd.b1af1ff3f1: no findings onb1af1ff3f1.baed687966: no findings onbaed687966.1485469260: no findings on1485469260.cf184f4385: no findings oncf184f4385.1e1da6fb0a: pending.