Repository navigation
perf(agents): wave-1 tool output contracts for code mode - #110215
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e4a183bc7f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
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".
| } | ||
| const envelope = parsed as { status?: unknown; value?: unknown }; | ||
| // Scalars deep-equal too easily; only structured raw returns count. | ||
| const value = envelope.status === "completed" ? envelope.value : undefined; |
There was a problem hiding this comment.
Handle tool_search_code's ok envelope
When the live bench runs the tool-search-code surface, tool_search_code results are wrapped by runCodeMode() as { ok: true, value, logs, telemetry } (src/agents/tool-search.ts:2240), but this detector only unwraps values when status === "completed". Because CODE_EXEC_TOOL_NAMES includes tool_search_code, raw-result inspection turns for that surface are never counted, so the new per-tool rawInspectionExecs metric is biased to zero for one of the surfaces this benchmark compares.
Useful? React with 👍 / 👎.
|
Codex review: needs changes before merge. Reviewed July 17, 2026, 7:28 PM ET / 23:28 UTC. Summary PR surface: Source +99, Tests +113, Docs +3, Other +288. Total +503 across 17 files. Reproducibility: yes. The source path is clear: run the live bench with a Review metrics: none identified. Stored data model Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Next step before merge
Security Review findings
Review detailsBest possible solution: Normalize the Code Mode Do we have a high-confidence way to reproduce the issue? Yes. The source path is clear: run the live bench with a Is this the best way to solve the issue? No. Owner-local output schemas are the right boundary, but the benchmark must account for the existing Code Mode envelope before it is used to rank avoided inspection turns. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against b42dc728510b. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +99, Tests +113, Docs +3, Other +288. Total +503 across 17 files. View PR surface stats
Acceptance criteria:
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
|
Merged via squash.
|
…0215) * feat(agents): keep output contracts complete across opaque schema leaves * test(agents): add code mode schema-hint hot-path micro-benchmark * test(agents): count raw-first inspection execs per tool in live bench * feat(agents): expand compact output contract hints * feat(agents): declare wave one tool output contracts * docs(tools): list built-in output contracts * fix(agents): bound union scans before literal-union analysis * fix(agents): keep wave-1 contract schemas module-local and type-exact
What Problem This Solves
Code Mode's quick index shows
-> ?for most built-in tools, forcing the model to spend a raw-inspection exec (a full model round trip) before it can filter or map a result. Only the conversation tools andagents_listdeclared output contracts — and theagents_listhint silently never rendered because its eight-literalagentRuntime.sourceunion exceeded the six-value literal cap.Two compactor semantics also blocked adoption: an explicitly opaque leaf (
Type.Unknown) demoted an otherwise-exact contract, and there was no per-tool measurement to rank which contracts pay for themselves.Why This Change Was Made
src/agents/tool-schema-hints.ts: an empty schema is JSON Schema's top type, so it now renders as a completeunknownleaf instead of demoting the whole contract; literal-union cap raised 6 -> 8 (combined 96-char bound unchanged) which repairs the deadagents_listhint; union scans are bounded in O(1) before any per-variant work.screen(byte-exactui.commandpassthrough, reusesUiCommandResultSchema),spawn_task,sessions_search,openclawdelegate, andterminal(four result families) with tool-local schemas at the owner boundary.scripts/repro/tool-surface-live-bench.ts: counts raw-first inspection execs per tool (exec result deep-equal to one recorded tool result), so future contract PRs are ranked by measured avoided turns.scripts/repro/tool-schema-hint-bench.ts: hot-path micro-benchmark for hint compaction, catalog assembly, and declared-output validation.User Impact
Code Mode agents see trusted declared output hints for six more built-in tools and compose them in one exec instead of paying an inspection turn. No tool result fields changed; untrusted MCP/client schemas remain excluded and fail-closed validation is unchanged.
Evidence
node scripts/run-vitest.mjs src/agents/tool-schema-hints.test.ts src/agents/tools/ src/agents/tool-search.test.ts src/agents/code-mode.test.ts— 66 files, 1521 tests green post-rebase.Value.Checkagainst executed results, exact compact-hint snapshots (or explicit absence).scripts/repro/tool-schema-hint-bench.ts— fullapplyCodeModeCatalog745 us per run attempt at 72 tools; typical hints 1.4-5.9 us/op; adversarial 5k-property schema bounded at ~465 us.fix(agents): bound union scans before literal-union analysis.