Repository navigation
feat(native-chat): model Codex MCP and web-search items instead of leaking opcodes - #18763
Conversation
…aking opcodes Codex's app-server sends 19 thread-item types; the structured translator handled six. The rest fell through to a generic gray `codex · item:<type>` row, even though the disposition table's own comment says it exists so a new item type cannot leak like that — the table had one entry. Give `mcpToolCall` and `webSearch` real tool-call bodies, and chrome `sleep`, which carries only a duration and renders as nothing in Codex's own TUI. `subAgentActivity` and `collabAgentToolCall` deliberately keep their generic rows. They arrive in real sessions today and are currently the only visible sign a subagent is running; hiding them before the subagent UI lands would render minutes of work as an idle turn. Tests pin that they stay visible. MCP tool names pass through verbatim when they contain `:`, `.`, `/` or `__`, so `mcp__server__tool` survives instead of being title-cased into nonsense.
📝 WalkthroughWalkthroughThe change moves Codex item identity helpers into a dedicated module and re-exports them. MCP translation preserves raw names and normalizes argument shapes. Web-search translation hoists action fields and serializes non-empty results. Journal dispatch handles MCP and web-search items. The provider-frame catalog classifies sleep as status chrome while preserving error precedence. Tests cover identities, translation, result handling, and frame classification. Merge Risk: 🟡 Moderate · up to Completed MCP calls can appear without their structured results, hiding useful tool output from users. Non-text results should be preserved before release. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description gives detailed scope, rationale, testing evidence, visual-proof status, and AI disclosure. However, it does not provide the required Linked Issue entry or the required checklist confirmations. Resolution Add a linked issue using the required
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
mcpToolCalltyped body — models server/tool/arguments/state/result-or-error as atool-callrow, withmcpToolDisplayNamekeeping namespaced tool names byte-identical and title-casing only bare words.webSearchtyped body — modelsquery/actionand derivesrunning/completedfrom the null-ness ofaction, matching Codex's own begin/end lifecycle.sleepchromed — added toCODEX_ITEM_CLASSIFICATIONSasstatus-chrome, with the payload-error check still outranking it.- Subagent + content-bearing types left visible —
subAgentActivity/collabAgentToolCalland the review/image/hook types keep their generic fallback rows, pinned by tests.
I verified the load-bearing schema claim independently against the open-source openai/codex (codex-rs) source rather than trusting the live-probe claim: McpToolCallItem (server, tool, arguments, camelCase status with a third failed value, error.message, result.content), WebSearchItem (query, Option<action>, Option<results>), and SleepItem ({id, durationMs}) all match the field names and shapes this PR reads. The one subtlety worth recording — that McpToolCallStatus also has a failed value the tests don't exercise — is already handled by commandState mapping any non-inProgress/completed status to failed. A stranded running web search (interrupted before WebSearchEnd) is also already settled to failed by interruptedBody at turn/session end, so it cannot hang permanently.
ℹ️ webSearch.results is dropped from the completed row
results carries the actual search findings (Option<Vec<JsonValue>>), but the typed body models only query/action, so a completed search shows what was asked and not what was found. This is a reasonable scope cut and not blocking — flagging only because the PR elsewhere goes out of its way to keep content-bearing fields visible, and results is a natural candidate for the same typed-body follow-up planned for the review/image types.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
Visual proofCaptured on a fresh isolated dev profile (Playwright/CDP), structured Codex route enabled (
|
… on the row
Four fixes to the Codex MCP / web-search item bodies:
- Drop the title-casing display name. `get_forecast` became `Get Forecast`,
which no longer matches the raw snake_case identifiers that the diff
renderer, question parsers, and tool-input previews dispatch on, and does not
match how the Claude lane or the sibling `shell`/`apply_patch`/`web_search`
bodies name a tool. The row name is now `server/tool` verbatim, the bare
`tool` when no server is given, and `mcp` when the item names no tool at all.
Server-qualifying also stops an MCP tool that happens to be called
`apply_patch` from hijacking the diff renderer.
- Pass the MCP call's own `arguments` as the tool input instead of wrapping it
in `{server, tool, arguments}`. Row-label derivation only reads top-level
keys, so the wrapper degraded every MCP row to a truncated raw JSON blob.
A non-object `arguments` stays addressable under a key rather than being
dropped; an absent one becomes null, which labels as empty rather than `{}`.
- Carry a web search's `results` as the call output, bounded like every other
inline payload and omitted when there are none. They were being dropped
entirely, which showed less than the generic fallback row it replaced.
- No streaming branches were added for these two item types: the Codex delta
stream is a closed set of six methods that neither can reach, so such
branches would be unreachable.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
mcpToolCallname now verbatim — the raw tool identifier is emitted (server/-qualified when a server is present,mcpwhen the tool is missing) instead of title-casing bare words, so downstream exact-match dispatch (the diff renderer'sEDIT_TOOL_NAMES) can actually match identifiers likestr_replace/apply_patchrather than theStr Replacethe old transform produced.mcpToolCallinput is the call's own arguments —argumentsare theinputdirectly so the row label can readquery/command/file_pathout of them; scalar/array args wrap under{arguments: …}and an absent arg isnull(labels empty, not{}).webSearchresults now surface as output —resultsis JSON-stringified and bounded into the completed row'soutput, resolving the prior review's note that search hits were dropped.
I traced the verbatim-name change through its consumers to confirm no regression: diffFromToolCall (EDIT_TOOL_NAMES) is exact-match so the raw name only fires for genuinely edit-shaped tools; COMMAND_TOOL_NAMES lowercases (normalizedToolName) so the icon/verb gating is unaffected; and createToolInputDisplay(null) handles the now-possible null input cleanly (empty label, no detail). The two changed test files pass (42 tests), with exact toEqual/toMatchObject/not.toHaveProperty assertions rather than loose ones.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
A row label is derived from top-level `input` keys only, so a webSearch
whose detail lives inside `action` — an opened page, an in-page find, or
a bare `other` — fell through to the raw JSON of the whole input, as did
the empty `query` Codex leaves on a completed search. Hoist the action's
`url`, `pattern` and `type` beside the query, keep the full `action`
object so the expanded detail loses nothing, and emit no input at all for
the start frame.
An MCP tool that takes no arguments sends `arguments: {}`, which passed
straight through and labelled the row a literal `{}`; treat it as absent
so the row reads as a bare `server/tool`.
Split the durable-identity half of the item translator into
`codex-thread-item-identity.ts`, re-exported so every existing import is
unchanged, to keep both files under the max-lines cap.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Argument-less MCP calls render as a bare
server/toolrow —mcpToolArgumentsnow maps{}(thearguments: {}shape an argument-less MCP tool actually sends on the wire) tonull, so the row labels itself with the tool name instead of a literal{}. - Web-search actions hoist labelable fields to the top level — the new
webSearchInputliftsurl,pattern, and the actiontype(landing ondescription, the lowest-ranked label key) besidequery, so everyWebSearchActionshape (search/openPage/findInPage/other) resolves to a real row label instead of the input's raw JSON, while the wholeactionstays for the expanded detail.
I verified the newly load-bearing WebSearchAction wire contract against the real codex-rs source rather than trusting the live-probe claim: it is #[serde(tag = "type", rename_all = "camelCase")] with Search { query, queries }, OpenPage { url }, FindInPage { url, pattern }, and #[serde(other)] Other, so the discriminator and every field name the helper reads are correct, and readString correctly rejects the Option fields that serialize as null. Both changed test files pass (44 tests), with exact toEqual/toBe assertions over every web-search shape.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
Visual proof (post-review-loop) — supersedes the earlier visual-proof commentCaptured on head This capture is after the two review-loop fix commits ( 1.
|
| Claim | Result |
|---|---|
MCP row name is raw server/tool, no title-casing |
Matched (node_repl/js, node_repl/ping) |
| MCP row label comes from the tool's own arguments, not the wrapper JSON | Matched ({"code":"7*191"}) |
Argument-less MCP call shows no literal {} |
Matched (bare node_repl/ping) |
| Web search row shows a human-readable label, not raw JSON | Not reproduced — no webSearch item fired |
| Expanding a row still shows full detail | Matched for both MCP cases |
Review loop status — merge-ready at
|
…em-coverage The one conflict was the tool-summary import in codex-structured-item-translation.test.ts; both arms are kept, since the merged file calls briefToolArg, createToolInputDisplay and describeToolInput. Combining both sides' additions pushed codex-structured-item-translation.ts to 325 effective lines against a 300-line cap, so this merge also splits it. Two pure moves, no behaviour change: - codex-item-field-readers.ts: readRecord, readString, readFirstString and readTextContent, the readers the whole translation module uses. - codex-command-action-class.ts: CommandActionClass, COMMAND_ACTION_CLASSES and commandActionFacts, Codex's own shell-call classification. The readers move rather than stay and re-export because the classification module needs them; leaving them behind would make the two modules a cycle. Both new modules are leaves; no existing importer changes.
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Team
Run ID: 84fb7b35-3096-42e7-a635-fd5dac8764e5
📒 Files selected for processing (7)
src/main/codex/codex-command-action-class.tssrc/main/codex/codex-item-field-readers.tssrc/main/codex/codex-structured-item-translation.test.tssrc/main/codex/codex-structured-item-translation.tssrc/main/codex/codex-thread-item-identity.tssrc/main/native-chat/agent-session-wire/provider-frame-disposition.test.tssrc/main/native-chat/agent-session-wire/provider-frame-disposition.ts
🚧 Files skipped from review as they are similar to previous changes (4)
- src/main/native-chat/agent-session-wire/provider-frame-disposition.test.ts
- src/main/native-chat/agent-session-wire/provider-frame-disposition.ts
- src/main/codex/codex-thread-item-identity.ts
- src/main/codex/codex-structured-item-translation.test.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
|
|
||
| function mcpToolCallItem(item: CodexThreadItem): CodexJournalItem { | ||
| const failure = readString(readRecord(item.error), 'message') | ||
| const text = failure ?? readTextContent(readRecord(item.result), 'content') |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Preserve non-text MCP results.
mcpToolCallItem reads only result.content as text. A successful result that contains only structuredContent, metadata, or non-text content creates a completed row with no output. Serialize the complete result, or use it as a fallback when no text content exists, before applying boundInlineText. Codex MCP results include content, structuredContent, and metadata. (github.com)
Proposed fix
- const text = failure ?? readTextContent(readRecord(item.result), 'content')
+ const result = readRecord(item.result)
+ const text =
+ failure ??
+ readTextContent(result, 'content') ??
+ (Object.keys(result).length > 0 ? JSON.stringify(result) : null)📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const text = failure ?? readTextContent(readRecord(item.result), 'content') | |
| const result = readRecord(item.result) | |
| const text = | |
| failure ?? | |
| readTextContent(result, 'content') ?? | |
| (Object.keys(result).length > 0 ? JSON.stringify(result) : null) |
…aking opcodes (stablyai#18763) * feat(native-chat): model Codex MCP and web-search items instead of leaking opcodes Codex's app-server sends 19 thread-item types; the structured translator handled six. The rest fell through to a generic gray `codex · item:<type>` row, even though the disposition table's own comment says it exists so a new item type cannot leak like that — the table had one entry. Give `mcpToolCall` and `webSearch` real tool-call bodies, and chrome `sleep`, which carries only a duration and renders as nothing in Codex's own TUI. `subAgentActivity` and `collabAgentToolCall` deliberately keep their generic rows. They arrive in real sessions today and are currently the only visible sign a subagent is running; hiding them before the subagent UI lands would render minutes of work as an idle turn. Tests pin that they stay visible. MCP tool names pass through verbatim when they contain `:`, `.`, `/` or `__`, so `mcp__server__tool` survives instead of being title-cased into nonsense. * fix(native-chat): keep Codex MCP tool identity and web-search results on the row Four fixes to the Codex MCP / web-search item bodies: - Drop the title-casing display name. `get_forecast` became `Get Forecast`, which no longer matches the raw snake_case identifiers that the diff renderer, question parsers, and tool-input previews dispatch on, and does not match how the Claude lane or the sibling `shell`/`apply_patch`/`web_search` bodies name a tool. The row name is now `server/tool` verbatim, the bare `tool` when no server is given, and `mcp` when the item names no tool at all. Server-qualifying also stops an MCP tool that happens to be called `apply_patch` from hijacking the diff renderer. - Pass the MCP call's own `arguments` as the tool input instead of wrapping it in `{server, tool, arguments}`. Row-label derivation only reads top-level keys, so the wrapper degraded every MCP row to a truncated raw JSON blob. A non-object `arguments` stays addressable under a key rather than being dropped; an absent one becomes null, which labels as empty rather than `{}`. - Carry a web search's `results` as the call output, bounded like every other inline payload and omitted when there are none. They were being dropped entirely, which showed less than the generic fallback row it replaced. - No streaming branches were added for these two item types: the Codex delta stream is a closed set of six methods that neither can reach, so such branches would be unreachable. * fix(native-chat): label Codex web searches and argument-less MCP calls A row label is derived from top-level `input` keys only, so a webSearch whose detail lives inside `action` — an opened page, an in-page find, or a bare `other` — fell through to the raw JSON of the whole input, as did the empty `query` Codex leaves on a completed search. Hoist the action's `url`, `pattern` and `type` beside the query, keep the full `action` object so the expanded detail loses nothing, and emit no input at all for the start frame. An MCP tool that takes no arguments sends `arguments: {}`, which passed straight through and labelled the row a literal `{}`; treat it as absent so the row reads as a bare `server/tool`. Split the durable-identity half of the item translator into `codex-thread-item-identity.ts`, re-exported so every existing import is unchanged, to keep both files under the max-lines cap. --------- Co-authored-by: Merge Sim <sim@local>









What
Codex's app-server sends 19 thread-item types. The structured translator handled 6. The rest degraded in one of two ways, neither good:
codex · item:<type>row (confirmed live forsubAgentActivity)statusrow carrying the streamed text, with no indication a tool had run at all(Two earlier revisions of this description put
mcpToolCallin that second group, via the catch-all incodexStreamingJournalItem. Both were wrong.CODEX_ITEM_STREAM_TYPESis a closed six-method map — agentMessage, plan, commandExecution, fileChange, and the two reasoning deltas — so neithermcpToolCallnorwebSearchcan reach that catch-all at all. Both landed in the first group: a generic gray row. The second group is real, but it is other item types.)Either way the disposition table's own comment says it exists precisely so a new item type cannot leak. It had one entry.
This models the two that carry real tool activity and chromes the one that carries nothing:
mcpToolCall→ a typed tool-call body (server, tool, arguments, result/error, state)webSearch→ a typed tool-call body (query, action, and the hits as output)sleep→status-chromeMCP tool names reach the row verbatim, always — no casing transform — qualified as
server/tool. Downstream dispatch (the diff renderer, the question parsers, the tool-input previews) matches raw identifiers, so any transform would silently miss them;server/also keeps two servers exposing the same tool distinguishable and stops an MCP tool coincidentally namedapply_patchfrom hijacking the diff renderer.(A first revision title-cased bare names —
get_forecastbecameGet Forecast— and passed through only names containing:,.,/or__. That escape hatch almost never fired, because the wire field carries the bare server-advertised tool name rather than themcp__server__toolcallable namespace. It has been removed.)Deliberately NOT hidden: the subagent items
subAgentActivityandcollabAgentToolCallkeep their generic rows in this PR, and there are tests pinning that.A live probe against
codex app-server0.152.1 confirmed these arrive in real sessions today. Their gray rows are currently the only visible evidence that a subagent is running. Chroming them now — before the subagent UI exists — would make a spawned subagent's minutes of work render as a completely idle turn. A follow-up PR gives them a real display; until then, an ugly row beats no row.Three candidates rejected after checking the schema
I originally proposed chroming four types. Checking each against Codex's generated schema and Rust source rejected three:
exitedReviewMode{id, review}looks opaque, but that field carries the review's overall explanation plus its full formatted findings block. Chroming it would silently swallow an entire code review's output.enteredReviewModereviewfield carries a hint written to be shown to the user.imageView{id, path}. Codex rendersimage: <path>; Orca'sNativeChatBlockalready has animage-refvariant keyed by path, so this is displayable content, not chrome.Also left alone for the same reason:
imageGeneration(carriesresult+savedPath),hookPrompt(fragments[].text),functionCallOutputanddynamicToolCall.Only
sleepsurvived the check —SleepItem = {id, durationMs}and nothing else, and Codex's own TUI returnsNonefor it, so it renders as nothing there too.The right fix for the other four is typed bodies in a follow-up, not classification. Hiding content is not the same as modelling it.
Scope guards
?? 'timeline-substantive'default inclassifyProviderFrameis untouched — it is also the fallback for unknown Claude frames and unknown Codex notification methods, so changing it would silently affect the Claude lane.hasProviderErrorordering is preserved; error payloads still reacherror-surfaceand stay exempt from the per-turn row cap."webSearch".toLowerCase()iswebsearch, which does not contain"web search";"agentMessage".includes("agent")istrue).Tests
44 passing across the two changed test files. Covers each new typed body, tool names surviving verbatim with no casing transform, argument-less and non-object MCP arguments, the five web-search shapes and their rendered labels,
sleepchroming, an error payload still routing toerror-surface, an unknown type still reaching the generic row — and the two subagent types still classifyingtimeline-substantiveat both the translation and disposition layers.The five dependent Codex journal test files were re-run green after the file split below. The changed-code quality gate reports 0 new findings across all 5 files (native, type-aware, React Doctor), and the max-lines ratchet passes.
A broad
src/main/codex+src/main/native-chatsweep showed intermittent failures, but an identical rerun produced a disjoint failure set and every one of them passes in isolation. Disjoint failure sets across identical runs cannot come from a deterministic code change, and none of those files import anything this PR touches — observed, dismissed as machine load, not a regression here.Review-loop follow-ups
Two review loops landed fixes on top of the original commit.
Validated against real captured Codex history, not hand-written fixtures. This is the strongest evidence on the PR, because both of the loop-2 defects were invisible to unit tests and to the original visual proof — the one MCP call captured there happened to have arguments. Measured over a real thread-history sample:
webSearchitems carry an emptyqueryon a completed item (mostlyaction.typeofother, someopenPage). Those rows rendered as raw JSON, because label derivation reads top-levelinputkeys only. The action'surl,patternandtypeare now hoisted beside the query —typelands ondescription, the lowest-ranked label key, so it names only an action carrying nothing better — while the fullactionobject stays in the input so the expanded detail loses nothing.mcpToolCallitems are argument-less tools sendingarguments: {}, which rendered the row a literal{}. A zero-key object is now treated as absent. The previous comment claimed anullbranch covered this, butargumentsis required by the schema, so that branch was effectively unreachable while the case that actually occurs got the bad outcome.Also fixed in loop 1: the
{server, tool, arguments}wrapper defeated the row label the same way (every MCP row degraded to a truncated JSON blob — the arguments are now the input, unwrapped, matching the Claude lane), andwebSearchdropped itsresultsentirely, which made the typed body a net content loss against the generic row it replaced.File split — audited as a pure move. The fixes pushed
codex-structured-item-translation.tspast the 300-line cap, and amax-linesdisable is not permitted, so the durable-identity concern moved tosrc/main/codex/codex-thread-item-identity.ts(37 effective lines; the translator is now 277). Every moved symbol —CODEX_MESSAGE_ITEM_TYPES,CodexThreadItem,isCodexMessageItemType,readCodexThreadItem,codexItemIdentity— was byte-compared against the pre-split file: no rewrite, no import cycle, and the original module re-exports them so all 7 existing importers are untouched. A reviewer should not need to redo that check.Visual proof. The comment thread carries a re-capture on the current head. The earlier visual-proof comment is deliberately left in place: it shows the pre-fix rendering (
Js {"server":"node_repl","tool":"js","arguments":{"code":"7*191"}}) and is now the receipt for two of the fixes above. A livewebSearchitem could not be produced — the provider reported the tool unavailable in that session — so that path is unit-tested only, and the proof comment says so rather than claiming coverage it does not have.🤖 Generated with Claude Code