Skip to content

improve: let Code Mode use declared tool result shapes#109813

Merged
steipete merged 15 commits into
mainfrom
codex/code-mode-output-contracts
Jul 17, 2026
Merged

improve: let Code Mode use declared tool result shapes#109813
steipete merged 15 commits into
mainfrom
codex/code-mode-output-contracts

Conversation

@steipete

@steipete steipete commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Related: #109288
Follow-up to #109651 and #109290

AI-assisted: Yes (Codex)

What Problem This Solves

Code Mode learned exact tool ids and compact input signatures from #109651, but every tool result still appeared as unknown. Even when a tool had a stable structured result, models often spent one exec returning the raw value and another exec processing fields they could have known up front. This left avoidable model turns, tokens, and latency in common multi-operation workflows.

Why This Change Was Made

Trusted OpenClaw core and plugin tools can now declare an optional outputSchema for AgentToolResult.details. Code Mode and Tool Search expose a bounded TypeScript-style output hint only when that schema is complete and closed; open, oversized, unsupported, MCP, and client schemas remain unknown and raw-first.

OpenClaw compiles trusted output schemas before execution, then validates final details after normal hooks. The embedded executor converts accepted results into deep-frozen JSON-safe snapshots before queuing transcript projections, preserves the result envelope's details presence marker, validates that exact snapshot, and returns it for a second host-boundary acceptance pass; rejected or later-mutated values therefore cannot enter session history as successful hidden-tool results, and an explicit details: undefined cannot redirect unwrapping or validation to the whole envelope. Framework-owned pre-execution policy blocks remain outside the success schema and are recognized by object identity, so calls reject with the denial reason before generated code can treat a block as a successful value; tool-authored blocked lookalikes still fail validation. Runtime/provider normalization preserves the result contract when it clones tool definitions. The compact renderer has strict depth/property/character/union bounds and normalizes AJV-style nullable schemas so every validator-accepted null remains visible to generated code. Remote and client schemas stay deferred as input: "unknown" and use object identity for catalog reuse, preventing attacker-sized metadata walks while preserving schema-replacement invalidation. agents_list adopts the contract as the first built-in example.

The change also promotes Code Mode to a dedicated /tools/code-mode documentation page with Quickstart, runtime semantics, guest API, output-contract authoring, trust/validation rules, fallback behavior, debugging, and validation guidance. The old /reference/code-mode route redirects to it.

Maintainer Decision

Approve outputSchema as the supported optional plugin API for describing and validating AgentToolResult.details across Code Mode and Tool Search. Tools that omit it retain existing behavior. Opted-in tools get pre-execution schema compilation, final-details validation, and framework-owned policy-result preservation.

User Impact

Code Mode can call and process tools with declared result shapes in the first exec instead of paying a raw-inspection round trip. Unknown outputs keep the safe existing raw-first behavior. Plugin authors get one documented result contract shared by Tool Search and Code Mode, without trusting remote MCP or client schema claims.

Evidence

Live multi-provider matrix: four validated Code Mode tasks per provider over the real Agent runtime and a 72-tool catalog with adversarial decoys. Baseline is merged #109651; after is this branch.

Metric Before After Change
Validated tasks 11/12 12/12 +1
Model turns 29 26 -10%
Code Mode exec calls 17 14 -18%
Decoy calls 0 0 unchanged
Total latency 81.4s 70.4s -13%
Input tokens 38,827 36,025 -7%
Output tokens 2,388 2,380 unchanged

Stress: three complete Code Mode matrices produced 34/36 validated tasks, 78 turns, 42 exec calls, 57 underlying service calls, and zero decoy calls. Anthropic and Google were 12/12; OpenAI was 10/12. Both misses were the model filtering singular fixture value plum with the plural word plums after selecting the correct real tool, not a discovery, transport, schema, or decoy failure. A final OpenAI/Google pass kept every completed task at two turns and one exec. The final Anthropic retry hit provider overload before tokens or tools; earlier Anthropic stress was 12/12.

Validation:

  • Exact final head: 276 focused tests passed across the live-bench parser, Code Mode, Tool Search, transcript projection ordering, explicit undefined result markers, runtime normalization, schema hints, agents_list, plugin SDK, descriptor cache, and optional tool metadata.
  • Blacksmith Testbox: the final projection patch passed exact 4-file core/test typechecks, lint with zero warnings or errors, SDK API/boundary checks, import-cycle analysis, formatting, and architecture guards. An earlier branch-wide Testbox pass also completed 254 focused tests, all changed gates, and the full production build. Fresh hosted CI runs again before merge.
  • Adversarial regressions cover malformed schemas before side effects, post-hook result validation, validation before transcript projection, immutable accepted-result snapshots, explicit undefined result markers, mutation after executor acceptance, policy-block rejection with preserved reason, blocked-lookalike rejection, nullable scalar/object contracts, cloned runtime tools retaining hints and validation, schema replacement, empty/oversized/intersected unions failing closed, closed/truncated/unsupported shapes, huge keys/catalogs, untrusted client/MCP schema deferral, and zero traversal of hostile schema proxies.
  • Source-blind behavior contract: satisfied at 0.86 confidence; all seven clauses passed, including state-changing irrigation, missing-tool recovery, zero decoys, provider-error classification, and docs navigation/redirect behavior.
  • Autoreview: final full branch clean at 0.86 confidence; explicit undefined-marker fix clean at 0.97; union fail-closed fix clean at 0.96; projection-order and immutable-snapshot fix clean at 0.92; runtime-normalization fix clean at 0.97; policy-block contract fix clean at 0.95; nullable-contract fix clean at 0.94. Earlier review-driven fixes added pre-execution compilation, explicit completeness tracking, unsupported-shape rejection, bounded untrusted metadata handling, and the documented input: "unknown" sentinel.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime scripts Repository scripts agents Agent runtime and tooling extensions: codex size: L maintainer Maintainer-authored PR labels Jul 17, 2026
@steipete steipete self-assigned this Jul 17, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b928540ce7

ℹ️ 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".

Comment thread src/agents/tool-search.ts
@steipete
steipete force-pushed the codex/code-mode-output-contracts branch from b928540 to 40a5f61 Compare July 17, 2026 09:00
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Jul 17, 2026
@clawsweeper

clawsweeper Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 17, 2026, 9:36 AM ET / 13:36 UTC.

Summary
The branch adds an optional outputSchema contract for AgentToolResult.details, propagates and validates it across Code Mode, Tool Search, runtime and plugin boundaries, documents it, and adopts it for agents_list.

PR surface: Source +418, Tests +789, Docs +212, Generated 0, Other +48. Total +1467 across 33 files.

Reproducibility: not applicable. This PR proposes a new tool-result contract and performance capability rather than repairing a defined current-main failure. Its benefit is demonstrated through the supplied before/after live matrix.

Review metrics: 1 noteworthy metric.

  • Plugin API surface: 1 optional field added. outputSchema becomes a documented third-party tool contract whose semantics must remain stable after release.

Stored data model
Persistent data-model change detected: serialized state: src/agents/code-mode.ts. Confirm migration or upgrade compatibility proof before merge.

Merge readiness
Overall: 🦞 diamond lobster
Proof: 🦞 diamond lobster
Patch quality: 🦞 diamond lobster
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Risk before merge

  • [P1] This creates a supported Plugin SDK contract: once plugin authors depend on outputSchema, its validation, schema subset, and details semantics become compatibility-sensitive.
  • [P1] The change sits on transcript and session-state boundaries; a future ordering or snapshot regression could persist rejected or mutated hidden-tool results.
  • [P1] Trusted plugin schemas influence model-visible hints and validation around policy-blocked results, so the bounded traversal and framework-owned identity checks are security-sensitive even though the current patch fails closed.
  • [P1] Several exact-head CI and security lanes were still in progress in the supplied context; they should complete before merge.

Maintainer options:

  1. Approve after exact-head gates (recommended)
    Land the shared optional API after a qualifying owner accepts the contract and all Plugin SDK, agent-runtime, session, and security checks pass.
  2. Narrow to core-owned tools
    Remove the public Plugin SDK exposure while retaining an internal metadata path for selected built-in tools.
  3. Pause the API expansion
    Close or defer this branch if maintainers do not want to own long-term result-schema validation semantics.

Next step before merge

  • A qualifying owner should approve or narrow the public Plugin SDK contract and then let exact-head required checks gate the merge; no automated repair is currently indicated.

Maintainer decision needed

  • Question: Should outputSchema become the supported optional Plugin SDK contract for describing and validating AgentToolResult.details across Code Mode and Tool Search?
  • Rationale: The implementation is technically coherent, but adding a public plugin API and its permanent validation semantics requires explicit owner intent rather than automated acceptance.
  • Likely owner: steipete — The Code Mode performance series and this proposed API are concentrated in their recent merged and current work, making them the strongest available routing candidate.
  • Options:
    • Approve the shared contract (recommended): Accept the optional field and its fail-closed trusted-schema semantics after exact-head required checks complete.
    • Keep it internal: Limit declared output metadata to core-owned tools until the external Plugin SDK contract and compatibility policy are separately designed.
    • Pause output contracts: Retain unknown raw-first outputs and defer both model-visible hints and runtime validation until the API direction is settled.

Security
Cleared: No concrete security or supply-chain defect remains on the reviewed head; schema traversal is bounded, untrusted MCP/client claims remain deferred, policy blocks use private identity, and rejected values are kept out of successful projections.

Review details

Best possible solution:

Approve one documented optional outputSchema contract shared by Code Mode and Tool Search, retain unknown/raw-first behavior for omitted or untrusted schemas, and merge only after exact-head compatibility, Plugin SDK, session-projection, and security gates pass.

Do we have a high-confidence way to reproduce the issue?

Not applicable: this PR proposes a new tool-result contract and performance capability rather than repairing a defined current-main failure. Its benefit is demonstrated through the supplied before/after live matrix.

Is this the best way to solve the issue?

Yes technically: one optional schema attached to the existing AgentTool result boundary is narrower and less drift-prone than separate Code Mode and Tool Search metadata systems. Final acceptance still depends on maintainers choosing to support this public API.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against b48c8016237c.

Label changes

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body provides after-fix live multi-provider Agent-runtime output, adversarial-catalog measurements, exact-head focused results, and delegated gate evidence that directly exercise the changed behavior.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This is a well-proven performance and developer-API improvement with bounded user impact, not an urgent regression.
  • merge-risk: 🚨 compatibility: The PR adds a public Plugin SDK result contract and stricter behavior for tools that opt into validation.
  • merge-risk: 🚨 session-state: The implementation changes when hidden-tool results are accepted and projected into persistent transcript history.
  • merge-risk: 🚨 security-boundary: Trusted schema traversal and framework policy-block recognition affect what generated code may treat as successful tool output.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • feature: ✨ showcase: ClawSweeper spotlight: unusually compelling feature idea for maintainer attention. A single trusted result contract can remove an otherwise unavoidable model inspection turn while preserving unknown and untrusted outputs as fail-closed, making the idea unusually valuable for large tool catalogs.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body provides after-fix live multi-provider Agent-runtime output, adversarial-catalog measurements, exact-head focused results, and delegated gate evidence that directly exercise the changed behavior.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides after-fix live multi-provider Agent-runtime output, adversarial-catalog measurements, exact-head focused results, and delegated gate evidence that directly exercise the changed behavior.
Evidence reviewed

PR surface:

Source +418, Tests +789, Docs +212, Generated 0, Other +48. Total +1467 across 33 files.

View PR surface stats
Area Files Added Removed Net
Source 11 548 130 +418
Tests 9 804 15 +789
Docs 11 308 96 +212
Config 0 0 0 0
Generated 1 2 2 0
Other 1 49 1 +48
Total 33 1711 244 +1467

What I checked:

  • Public API surface: AgentTool gains the optional outputSchema field, making declared result shapes part of the supported tool and plugin contract. (packages/agent-core/src/types.ts:464, 17f0cb71be6b)
  • Plugin SDK propagation: Static tool-plugin definitions, metadata, descriptors, cached plugin tools, and runtime-normalized tools preserve the same schema object rather than introducing parallel metadata paths. (src/plugin-sdk/tool-plugin.ts:67, 17f0cb71be6b)
  • Transcript boundary: The embedded executor now accepts and validates the final snapshot before queuing the hidden-tool transcript projection, addressing the earlier session-history finding. (src/agents/embedded-agent-runner/run/attempt-stream-prepare.ts:308, 17f0cb71be6b)
  • Bounded schema hints: The renderer rejects unsupported, incomplete, oversized, intersected, and unrenderable union shapes instead of advertising a partial output contract. (src/agents/tool-schema-hints.ts:1, 17f0cb71be6b)
  • Regression coverage: Focused tests cover nullable results, malformed and oversized unions, hostile schema objects, policy-block identities, runtime cloning, immutable snapshots, explicit undefined markers, and projection ordering. (src/agents/tool-search.test.ts:312, 17f0cb71be6b)
  • Prior finding resolution: The previous unrenderable-union finding was addressed by commit 73a99025aa90d65b9307d95dd1c4a6ff02ce01a7; the current head also includes the explicit-details-marker repair in 2cc947dbcd572a7acb843d069c6730505f738243. (src/agents/tool-schema-hints.ts:1, 73a99025aa90)

Likely related people:

  • steipete: Authored the merged Code Mode performance predecessors and the current output-contract work across code-mode.ts, tool-search.ts, Plugin SDK metadata, docs, and the live benchmark. (role: feature owner and recent area contributor; confidence: high; commits: b39e1cf66f9a, c742caee4b61, b1eceb12da75; files: src/agents/code-mode.ts, src/agents/tool-search.ts, src/agents/tool-schema-hints.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
Review history (6 earlier review cycles)
  • reviewed 2026-07-17T09:06:10.278Z sha 40a5f61 :: found issues before merge. :: [P2] Describe the actual Codex Code Mode runtime | [P3] Remove the release-owned changelog entry
  • reviewed 2026-07-17T09:47:12.584Z sha 5ccb36c :: found issues before merge. :: [P2] Match Codex’s in-process V8 runtime contract | [P3] Remove the release-owned changelog entry
  • reviewed 2026-07-17T11:10:01.850Z sha 9b04bcb :: found issues before merge. :: [P2] Preserve outputSchema through runtime tool normalization
  • reviewed 2026-07-17T11:25:05.174Z sha bcb8096 :: found issues before merge. :: [P2] Preserve outputSchema through runtime tool normalization | [P2] Validate results before queuing transcript projections
  • reviewed 2026-07-17T11:48:55.593Z sha c164a6a :: found issues before merge. :: [P2] Validate before recording tool projections
  • reviewed 2026-07-17T12:43:16.764Z sha ab983fd :: found issues before merge. :: [P2] Treat unrenderable output unions as unknown

@steipete
steipete force-pushed the codex/code-mode-output-contracts branch 2 times, most recently from 5ccb36c to 70531c6 Compare July 17, 2026 09:52

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 70531c6ecb

ℹ️ 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".

Comment thread CHANGELOG.md Outdated
@steipete
steipete force-pushed the codex/code-mode-output-contracts branch from 7fbf9da to 7fa86fc Compare July 17, 2026 10:32

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7fa86fcb88

ℹ️ 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".

/** Human-readable label for UI display. */
label: string;
/** Optional schema for the structured `AgentToolResult.details` value. */
outputSchema?: TSchema;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge Preserve output schemas across tool normalization

In provider/model runs where a provider runtime or runtimePlan normalizer returns cloned tool objects (a supported path handled by normalizeAgentRuntimeTools / copyRuntimeToolMetadata), this new field is not copied with the existing plugin/channel/catalog metadata before applyCodeModeCatalog or applyToolSearchCatalog builds the catalog. The cloned tool therefore loses outputSchema, so Code Mode shows -> ? and skips the validation for exactly the providers that normalize schemas; copy outputSchema in that metadata-preservation step.

Useful? React with 👍 / 👎.

@steipete
steipete force-pushed the codex/code-mode-output-contracts branch from 7fa86fc to 9b04bcb Compare July 17, 2026 11:05

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9b04bcb1a5

ℹ️ 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".

Comment thread src/agents/tool-search.ts Outdated
});
// Hooks may replace details after execution, so validate the final catalog
// value at the host boundary before Code Mode trusts the declared shape.
await assertCatalogOutputMatchesSchema(entry, result);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge Do not record schema-rejected tool results

When this post-execution validation fails in a normal embedded run, the hidden target tool has already been recorded as a successful Tool Search projection: the production executor in src/agents/embedded-agent-runner/run/attempt-stream-prepare.ts pushes result before returning to ToolSearchRuntime, and src/agents/embedded-agent-runner/run/attempt-stream-settle.ts later projects every queued projection into the transcript. So a tool that declares outputSchema but returns mismatching details still has its rejected result content written into the conversation before the bridge/control tool reports the schema error, leaking exactly the value this gate is meant to suppress; validate before queuing the projection or defer projection until after this schema check succeeds.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 1e5c82f. The embedded executor now awaits an acceptance gate before queuing any hidden-tool projection. That gate creates a deep-frozen JSON snapshot, validates the snapshot, and returns the same accepted object for projection; the host repeats acceptance so custom executors cannot return a later-mutated value. Rejected results produce only the sanitized error projection. Added regressions for rejection-before-projection, delayed-settlement mutation, mutation after executor acceptance, and framework policy-block identity. Exact focused proof: 275/275. Final Testbox changed gate: core/test types passed, lint 0/0, SDK/boundary/import-cycle/architecture guards passed.

@steipete
steipete force-pushed the codex/code-mode-output-contracts branch from 9b04bcb to bcb8096 Compare July 17, 2026 11:20
@clawsweeper clawsweeper Bot added merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels Jul 17, 2026
@steipete
steipete force-pushed the codex/code-mode-output-contracts branch from c164a6a to f65d1f2 Compare July 17, 2026 11:54

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f65d1f2719

ℹ️ 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".

Comment thread src/agents/tool-schema-hints.ts Outdated
Comment on lines +108 to +109
if (!variants || variants.length === 0 || variants.length > MAX_COMPACT_UNION_TYPES) {
return undefined;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge Do not fall through after unrenderable output unions

When a trusted outputSchema has anyOf/oneOf alongside a base type/properties but the variants are empty or exceed the compact limit, this returns undefined, and compactSchemaType then continues to render the base schema as a complete hint. In that case Code Mode can advertise an output shape that omits required union variants, so the model may skip describe and process missing fields in the first exec; return an incomplete/unknown hint whenever a union keyword is present but cannot be compacted.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 85df5e7. Union presence is now fail-closed: malformed, empty, oversized, dual anyOf/oneOf, or base-structural intersections return an incomplete hint instead of falling through to type/properties/const/enum rendering. Added base-object regressions for empty oneOf, a five-variant anyOf, and both union keywords. Focused proof: 6/6; autoreview clean at 0.96 confidence. Fresh exact-head CI is running.

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. feature: ✨ showcase ClawSweeper spotlight: unusually compelling feature idea for maintainer attention. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Jul 17, 2026
@steipete
steipete force-pushed the codex/code-mode-output-contracts branch from 65d8afc to 2cc947d Compare July 17, 2026 13:26
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Jul 17, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 17f0cb71be

ℹ️ 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".

});
// Settlement persists every queued projection. Validate the final result
// first so a rejected hidden-tool value never enters session history.
const acceptedResult = await toolParams.acceptResultBeforeProjection(result);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge Validate hidden outputs before lifecycle success

When a hidden Code Mode/Tool Search target declares outputSchema and returns mismatching details, this acceptance gate runs only after subscription.runToolLifecycle has already completed. I checked src/agents/embedded-agent-subscribe.ts:1413-1421: that lifecycle helper passes the raw result to handleToolExecutionEnd, and src/agents/embedded-agent-subscribe.handlers.tools.ts:1510-1519 emits it on the tool event stream/onAgentToolResult before validation rejects it, so rejected values still leak as successful tool results outside the transcript projection. Fresh evidence beyond the earlier transcript finding is that the current head still emits the raw lifecycle result before this line; move acceptance into the lifecycle execute closure or otherwise emit only the accepted/error result.

Useful? React with 👍 / 👎.

@steipete
steipete merged commit b319493 into main Jul 17, 2026
136 of 142 checks passed
@steipete
steipete deleted the codex/code-mode-output-contracts branch July 17, 2026 13:46
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 18, 2026
* feat(agents): add Code Mode output contracts

* perf(agents): defer untrusted tool schemas

* chore(plugin-sdk): refresh API baseline

* fix(agents): preserve deferred schema markers

* fix(agents): preserve policy-blocked tool results

* fix(agents): preserve nullable output contracts

* fix(agents): reject policy blocks from success contracts

* fix(agents): preserve output contracts through normalization

* test(agents): type normalized tool fixtures

* fix(agents): validate catalog results before projection

* fix(agents): keep result snapshots internal

* fix(agents): fail closed on unrenderable unions

* fix(agents): preserve empty result markers

* test(agents): keep result fixture discriminator literal

* test(agents): use native own-property check
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation extensions: codex feature: ✨ showcase ClawSweeper spotlight: unusually compelling feature idea for maintainer attention. gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. scripts Repository scripts size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant