Skip to content

improve(llm-task): constrain Codex output with task schemas - #137450

Merged
steipete merged 6 commits into
openclaw:mainfrom
cavit99:fix/llm-task-codex-output-schema
Oct 25, 2026
Merged

steipete merged 6 commits into
openclaw:mainfrom
cavit99:fix/llm-task-codex-output-schema

Conversation

@cavit99

@cavit99 cavit99 commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Closes #137432

What Problem This Solves

llm-task validates its schema only after generation, so Codex-backed tasks can return valid JSON with missing fields or incorrect types despite native structured-output support.

User Impact

Small task schemas can constrain isolated Codex generation. Schemas outside the native strict subset receive at most one prompt-constrained retry on the same route, within the original deadline. Local JSON parsing and schema validation remain authoritative.

Why This Change Was Made

Pass the optional advisory outputSchema through the existing isolated-completion owners to turn/start. Preserve the documented 1 KiB forwarding budget, tool isolation, authentication, cancellation, and usage observation. Retry only an explicit native schema rejection, including Codex's HTTP-formatted 400 response; unrelated failures do not retry. Validate the exact submitted fallback input through the existing passive-turn attestation.

Original implementation by @cavit99 (Cavit Erginsoy); contributor commits are preserved.

Evidence

  • Main a0b170fac1ac regression: bounded-turn-output-schema.test.ts fails because turn/start.outputSchema is absent. The same regression passes with this change.
  • A transport-shaped native HTTP rejection also failed before the classifier repair and passes afterward. Generic 400/429 failures, deadline expiration, and revoked caller authority do not start another turn.
  • Focused Codex and llm-task suites: 64 passed (220.17 seconds wall). Final runtime, prefix-stability, finalizer, and schema checks: 100 passed (208.22 seconds wall); most time was worker compilation/imports.
  • Changed-file formatting, whitespace checks, core type-aware lint, and extension syntax lint passed. Extension type-aware lint is locally blocked by the nested-checkout/shared-install declaration guard; PR CI provides broad type/lint proof.
  • After the final main integration (no feature-code changes), two local rerun attempts failed before collection because the shared canonical debug installation cannot resolve ms; no assertions ran. Exact-head CI must cover this remaining environment gap.
  • pnpm prompt:snapshots:gen completed with no snapshot delta. Independent P0–P2 review is clean after repairing native HTTP rejection classification.
  • Current-head live provider inference was not run: the existing opt-in real-binary test selects the operator's Codex home, and no task-scoped provider credentials were used. Boundary tests cover the changed request and recovery path.
  • Against integrated main: production +114/-17 (net +97), tests/fixtures +397/-7 (net +390), docs +48/-5. The production growth carries the optional field through existing owners, budgets it, and implements the bounded retry; redundant retry state and the separate prompt helper were removed. Original proposal: +512/-26 across 26 files; current candidate: +559/-29 across 27 files, with the increase primarily regression coverage.

CI and review notes

Exact-head CI run 40166637781 reports an unrelated check-lint failure at test/helpers/claude-managed-settings.ts:21: no-recursive-readdir rejects the helper's forwarded options. Current main e8b251188f502b088dd037936062a1711ea302e1 fails the same focused command, node scripts/run-oxlint.mjs --openclaw-focused-config --config config/oxlint/resource-safety.json test/helpers/claude-managed-settings.ts. Both the helper and rule module have identical Git blob hashes on main and this head. The newest scheduled main run, 40165856223, predates the rule change and passed lint; it is not claimed as a matching failing run. This baseline defect remains outside the schema feature.

ClawSweeper found no code or security defect on this head. Its live-proof request remains covered by the limitation above. Documentation examples use a stable public model ID; they do not change runtime defaults. The core harness-forwarding assertion remains because the runtime-broker and native-client suites mock opposite sides of that boundary and cannot replace its dispatch coverage.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation extensions: llm-task Extension: llm-task agents Agent runtime and tooling extensions: codex plugin: file-transfer size: M labels Sep 3, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 3, 2026
@clawsweeper

clawsweeper Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR forwards small task schemas to isolated Codex generation and retries once after an explicit native-schema rejection.

Example: A task requires an object with a string answer, using required:["answer"] and additionalProperties:false.

  • Before: Codex generates without that constraint, and llm-task rejects a result such as {"answer":7} afterward.
  • After: Codex receives the schema during generation, while llm-task still validates the returned JSON.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The implementation is focused and no concrete bug was found, but required real-behavior proof is absent and product acceptance remains unresolved.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Feature · Worth it: Needs a maintainer decision · Fix scope: Complete
User problem: Schema-backed tasks can fail after generation because otherwise valid JSON omits required fields or uses incorrect types.
Reason: Native generation constraints offer clear value, but the optional public SDK field and automatic additional inference attempt remain product choices without explicit recorded approval.

Merge readiness

⛔ Blocked before merge - 4 items remain

This PR adds a useful capability absent from current main, with no concrete correctness finding; its paired request and maintainer engagement warrant keeping it open.

Priority: P2
Reviewed head: 49e7af257bd03a8bdcaf54dd79941ff7b373a8cf
Owner decision: Required. See Decision needed.

Decision needed

  • Question: Should isolated completions expose advisory outputSchema and automatically retry once after an explicit Codex schema rejection?
  • Recommendation: Accept the bounded capability: Approve the optional field and one same-route retry within the original deadline, retaining the forwarding budget and local validation.
  • Why: The public SDK expansion and additional inference attempt need an owner decision; repair commits and a re-review request do not explicitly settle that direction.

Before merge

  • Add real behavior proof - The llm-task-to-Codex schema handoff and rejection recovery are supported by mocked-client tests, while the body explicitly excludes current-head live inference; provide terminal output or redacted logs from a real llm-task invocation showing native acceptance and one rejection fallback, with IPs, keys, phone numbers, and private endpoints removed. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.
  • Complete next step - Explain why schema support requires the model-example substitutions in docs/tools/llm-task.md and docs/plugins/sdk-runtime/models.md, or restore those examples.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.
  • Explain or restore the original intent of Published model examples - f9ccd07: Align production examples with the selected default model; this PR also substitutes older example selections without explaining their connection to schema support.

Findings

None.

Provenance

  • Published model examples changes intended behavior without addressing why it exists (f9ccd07: Align production examples with the selected default model; this PR also substitutes older example selections without explaining their connection to schema support.)

Tests

  • Low-value test src/agents/isolated-completion.test.ts: Remove or consolidate the added forwarding-only mock assertion; it checks an intermediary call shape while adjacent broker and Codex request tests already cover schema propagation.
  • Missing end-to-end proof: Supply a redacted shipped-entry-point run showing native schema acceptance and explicit schema-rejection recovery through the real Codex client; the body reports a base-red/head-green regression, but this review executed no tests.
Agent review details

How this fits together

The optional llm-task plugin sends a fresh inference request through the host completion broker and selected harness; Codex returns text that the plugin parses and validates.

flowchart LR
A[Workflow caller] --> B[llm-task plugin]
B --> C[Isolated completion broker]
C --> D[Selected Codex harness]
D --> E[Native bounded turn]
E --> F[JSON parsing and validation]
F --> A
Loading

Technical review

Best possible solution:

Use the existing completion broker and Codex bounded-turn owner for advisory schemas, preserving authoritative local validation and the original execution deadline.

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

Current-main source establishes the missing schema handoff, but no live generation failure was reproduced and existing post-generation validation follows its documented contract.

Is this the best way to solve the issue?

The patch uses the appropriate existing owners and bounds recovery without changing runtime selection, tool isolation, or local validation.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against e8b251188f50.

Provenance checked

  • Isolated completion and retry semantics changes intended behavior with a stated reason (ce67ffb: Provide fresh tool-free inference through the selected runtime without fallback to a different runtime.)
  • Passive output and managed-hook validation keeps the original intent (bab6b05: Share passive-item and prompt-echo validation while preserving the settled-turn no-replay boundary; the patch extends exact matching to the actual fallback input.)
  • Schema reference ownership keeps the original intent (07d6588: Admit plugin values at their owning boundary and retain reference ownership rather than reconstructing them.)

Testing

Proof path: unit tests only.

Security

None.

Evidence

What I checked:

PR surface

Source +97, Tests +390, Docs +43. Total +530 across 27 files. Added test files: 2.

View PR surface stats
Area Files Added Removed Net
Source 13 114 17 +97
Tests 10 397 7 +390
Docs 4 48 5 +43
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 27 559 29 +530

Review metrics

Metric Value Why it matters
Public contract expansion 1 optional caller field and 1 matching V2 harness field The advisory schema becomes part of the plugin completion and harness contracts.
Recovery bounds 1,024 UTF-8 bytes; at most 1 schema fallback Additional model context is bounded, and recovery shares the original deadline.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #137432
Summary: This PR implements the paired request for native schema constraints during isolated Codex generation.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit. Replaced prior rating: 🦐 gold shrimp.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.
  • remove proof: sufficient: Current real behavior proof status is mock_only, not sufficient.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🧂 unranked krab, so this older rating label is no longer current.
  • remove status: ⏳ waiting on maintainer: Current PR status label is status: 📣 needs proof.

Label justifications:

  • P2: Schema-backed automation gains a focused generation-reliability improvement with limited blast radius.
  • merge-risk: 🚨 compatibility: The public completion contract gains an optional parameter, and existing schema-backed Codex calls can initiate an additional inference attempt; that acceptance is tracked in the maintainer decision.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit. Replaced prior rating: 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (22 earlier review cycles; latest 8 shown)
  • reviewed 2026-10-01T08:18:04.310Z sha 0a48826cec51caf70dfc4fa1e3bb89fff5120e5b :: blocked before merge. :: none
  • reviewed 2026-10-11T10:55:25.938Z sha cae92b187157840e7159e7886473ee6690aca89d :: blocked before merge. :: [P2] Preserve reference ownership for the admitted schema
  • reviewed 2026-10-11T12:23:40.474Z sha 064ebf5b955f6783fb518b9e3cb6eb39717eef96 :: blocked before merge. :: none
  • reviewed 2026-10-11T14:21:46.427Z sha 064ebf5b955f6783fb518b9e3cb6eb39717eef96 :: blocked before merge. :: none
  • reviewed 2026-10-11T14:52:57.624Z sha 064ebf5b955f6783fb518b9e3cb6eb39717eef96 :: blocked before merge. :: none
  • reviewed 2026-10-11T17:40:29.403Z sha 064ebf5b955f6783fb518b9e3cb6eb39717eef96 :: blocked before merge. :: none
  • reviewed 2026-10-11T18:45:24.253Z sha 064ebf5b955f6783fb518b9e3cb6eb39717eef96 :: blocked before merge. :: none
  • reviewed 2026-10-22T19:24:40.499Z sha 09d2f4e :: blocked before merge. :: none

Reviewed October 25, 2026, 1:50 AM ET / 05:50 UTC (Revision 23).

@cavit99
cavit99 force-pushed the fix/llm-task-codex-output-schema branch from b33d504 to 219c605 Compare September 3, 2026 18:05
@cavit99
cavit99 force-pushed the fix/llm-task-codex-output-schema branch from 219c605 to f58d840 Compare September 3, 2026 18:16
@cavit99
cavit99 marked this pull request as ready for review September 3, 2026 18:16
@clawsweeper

clawsweeper Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-25T07:57:17.954370Z
We couldn’t complete this review. Comment @codex review to try again.
42eeaf4 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@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: f58d8407be

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

@cavit99
cavit99 force-pushed the fix/llm-task-codex-output-schema branch from f58d840 to 82b4029 Compare September 3, 2026 18:47
@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: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 3, 2026
@cavit99
cavit99 force-pushed the fix/llm-task-codex-output-schema branch from 82b4029 to b79f99e Compare September 10, 2026 11:00
@cavit99

cavit99 commented Sep 10, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added the rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. label Sep 10, 2026
@cavit99
cavit99 force-pushed the fix/llm-task-codex-output-schema branch from 6337947 to 09d2f4e Compare October 22, 2026 08:18
@openclaw-barnacle openclaw-barnacle Bot added triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. and removed triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Oct 22, 2026
@roboclaw-bot roboclaw-bot added the clawtributors PR from a clawtributor label Oct 22, 2026

cavit99 commented Oct 22, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Please review current head 09d2f4e4a09ae410bf13d7aae2e4c96840d18da9. The branch is rebased, with three test-only adaptations to the current Codex client API. CI and applicable security checks pass; the PR body records current evidence and remaining local build/live-proof limits. Maintainer acceptance of the public schema field and bounded fallback remains pending.

@clawsweeper

clawsweeper Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Oct 22, 2026
@steipete

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added the clawsweeper:intake:feature Preliminary submission classification; full source review pending. label Oct 25, 2026
@steipete
steipete merged commit 98b7887 into openclaw:main Oct 25, 2026
120 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 26, 2026
…#137450)

* improve(llm-task): constrain Codex output with task schemas

* test(codex): attest settled finalizer input

* test(codex): adapt schema coverage to current client lifecycle
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling clawsweeper:intake:feature Preliminary submission classification; full source review pending. clawtributors PR from a clawtributor docs Improvements or additions to documentation extensions: codex extensions: llm-task Extension: llm-task merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. plugin: file-transfer proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: L status: ⏳ waiting on maintainer Only explicit maintainer approvals or decisions remain; merge is still blocked.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Use task schemas during Codex-backed llm-task generation

3 participants