Skip to content

fix: report native session model facts to context engines - #146801

Merged
steipete merged 1 commit into
mainfrom
codex/swarm-native-model-provenance
Sep 13, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/swarm-native-model-provenance

Conversation

@steipete

@steipete steipete commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Related: #130741

What Problem This Solves

Fixes an issue where a context-engine plugin could receive the wrong model and unverified context limits after a turn in a native-owned session. A resumed native session can select a different model from the surrounding OpenClaw configuration.

Why This Change Was Made

Use the model/provider tuple reported by the prepared native session for accepted-turn context. A native model tuple does not establish that the host context window or token budget applies, so those values are omitted for that result. Other turns retain their existing model and budget fields.

User Impact

Context-engine plugins receive model facts from the owner of the completed native turn. Native model selection, credentials, configured limits, transcript authority, and durable outbox processing keep their existing contracts.

Evidence

The new cases failed on the original code for the intended model-attribution and unsupported-budget errors. After the repair, all 219 selection, ownership, backend and durable context-engine tests passed. Six existing synthetic Codex app-server boundary cases also passed. All tests used Node 24.21 with one worker; the assertions and timeouts stayed unchanged. Independent P1 review found no actionable defects.

The native files are unchanged after refreshing onto current main, so their focused tests, canonical checks and P1 review remain valid. The eight terminal-context cases also passed on the prior integration. The fresh-main comparison confirmed that all 34 audited native ownership, protocol, focused-test, support, manifest and Vitest-routing inputs are unchanged. The upstream sidebar and test-inventory CI fixes are inherited from main; this PR carries only the native two-file delta.

This is focused correctness evidence; native live and integrated Swarm responsiveness proof remain part of the parent campaign.

@clawsweeper

clawsweeper Bot commented Sep 13, 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.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S maintainer Maintainer-authored PR labels Sep 13, 2026
@steipete
steipete marked this pull request as ready for review September 13, 2026 06:31
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 13, 2026
@clawsweeper

clawsweeper Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 13, 2026, 3:53 AM ET / 07:53 UTC (Revision 3).

ClawSweeper review

What this changes

Report the native session’s actual provider and model to context-engine plugins after a turn, omit unattested host limits, and extend regression coverage.

Merge readiness

✅ Ready for maintainer review

This remains a useful, focused correction absent from the inspected main revision. No actionable correctness or security defect was found, and the maintainer-authored, protected PR should remain open for normal landing.

Priority: P2
Reviewed head: fc9073654f07d31761a26703e63e716a03eca2c4

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A small, coherent producer correction with meaningful regression coverage and no identified blocking defect.
Proof confidence 🌊 off-meta tidepool Not applicable: The maintainer-authored PR is exempt from the external-contributor proof gate. Its focused selection tests cover the changed callback; native live proof is explicitly deferred, and parent Swarm media does not demonstrate this metadata handoff.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The maintainer-authored PR is exempt from the external-contributor proof gate. Its focused selection tests cover the changed callback; native live proof is explicitly deferred, and parent Swarm media does not demonstrate this metadata handoff.
Evidence reviewed 8 items Introduced scope and current-main necessity: The pinned introduced delta changes only selection.ts and its regression tests. Inspected main still unconditionally copies the host provider, model, context window, and token budget into the terminal callback. The host-verified test merge also limits its changes to these two files.
Existing optional model-facts contract: ContextEngineTurnRuntimeContext already makes all four model facts optional. Accepted-turn finalization and outbox delivery carry that object through to commitTurn without reconstructing missing limits. The patch changes supplied facts, not the payload schema, stored configuration, or acceptance authority.
Native tuple producer and dependency signal: The Codex adapter derives runtimeModelSelection from the prepared thread when preserveNativeModel is active. Its resume path consumes the app-server response model/provider, establishing a concrete dependency on the Codex thread-resume contract.
Findings None None.
Security None None.

How this fits together

Agent harnesses execute model turns and pass accepted-turn facts to OpenClaw’s durable context-engine pipeline. Context-engine plugins use those facts when recording completed turns and managing conversation context.

flowchart TD
  A[Prepared session] --> B[Agent harness executes turn]
  B --> C[Completed turn and model facts]
  C --> D{Native runtime and model tuple?}
  D -->|Yes| E[Native provider and model]
  D -->|No| F[Host model and limits]
  E --> G[Accepted-turn outbox]
  F --> G
  G --> H[Context-engine plugin]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +7, Tests +44. Total +51 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 13 6 +7
Tests 1 56 12 +44
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 69 18 +51

Review metrics

None.

Technical review

Best possible solution:

Keep model attribution with the prepared native session and report limits only when their applicability is established.

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

Yes, from source: a prepared native session can return a different model tuple while current main reports the outer host tuple and limits. The added callback regressions cover that mechanism; no runtime reproduction was executed here.

Is this the best way to solve the issue?

Yes. The patch corrects the existing producer, preserves ordinary host-budget reporting, and uses already-optional metadata without adding a competing model-selection path.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: Corrects bounded post-turn model attribution for context-engine plugins without changing inference routing or user configuration.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The maintainer-authored PR is exempt from the external-contributor proof gate. Its focused selection tests cover the changed callback; native live proof is explicitly deferred, and parent Swarm media does not demonstrate this metadata handoff.

Evidence

What I checked:

  • Introduced scope and current-main necessity: The pinned introduced delta changes only selection.ts and its regression tests. Inspected main still unconditionally copies the host provider, model, context window, and token budget into the terminal callback. The host-verified test merge also limits its changes to these two files. (src/agents/harness/selection.ts:408, 65c8b06f2e42)
  • Existing optional model-facts contract: ContextEngineTurnRuntimeContext already makes all four model facts optional. Accepted-turn finalization and outbox delivery carry that object through to commitTurn without reconstructing missing limits. The patch changes supplied facts, not the payload schema, stored configuration, or acceptance authority. (src/agents/harness/context-engine-turn-outbox.ts:30, fc9073654f07)
  • Native tuple producer and dependency signal: The Codex adapter derives runtimeModelSelection from the prepared thread when preserveNativeModel is active. Its resume path consumes the app-server response model/provider, establishing a concrete dependency on the Codex thread-resume contract. (extensions/codex/src/app-server/run-attempt-active-turn.ts:81, fc9073654f07)
  • Personally inspected dependency implementation: The sibling checkout was verified through its cache repository remote as openai/codex at the recorded SHA. Thread-resume responses obtain model and model_provider from the session configuration; the warm-resume implementation likewise uses its configuration snapshot. This supports consuming the native tuple without treating it as evidence of a host token budget. (codex-rs/app-server/src/request_processors/thread_processor.rs:4006, 3d2ee51ca2d5)
  • Regression coverage and proof scope: The eight terminal-context cases exercise missing anchors, native and host authentication ownership, matching and differing native tuples, and absent native facts. The captured PR body reports before-fix failures and 219 passing focused tests, plus six synthetic app-server cases; these were not executed during this read-only review. (src/agents/harness/selection.test.ts:1146, fc9073654f07)
  • Prior budget repair and release boundary: GitHub confirms fix: retain model budgets for durable context-engine turns #142871 merged on September 11 and introduced host model facts for durable turns. Its body explicitly supports older rows without metadata. The inspected v2026.9.4 selection callback predates that metadata addition, so it does not contain this native-attribution correction. The present patch retains the earlier repair for ordinary turns. (src/agents/harness/selection.ts, d6997b6bbf2e)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Marvinthebored: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • 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.

History

Review history (2 earlier review cycles)
  • reviewed 2026-09-13T06:39:05.578Z sha f19cdaa11f5ffd8d883af42281ad1222dbed6cb3 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-13T07:16:51.567Z sha 1bd5cd40e6d49208d0965e8508672cfaedd136b0 :: needs maintainer review before merge. :: none

@steipete
steipete force-pushed the codex/swarm-native-model-provenance branch 2 times, most recently from 1bd5cd4 to fc90736 Compare September 13, 2026 07:46
@steipete
steipete force-pushed the codex/swarm-native-model-provenance branch from fc90736 to c003695 Compare September 13, 2026 09:36
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Sep 13, 2026
@steipete
steipete merged commit b938f09 into main Sep 13, 2026
186 checks passed
@steipete
steipete deleted the codex/swarm-native-model-provenance branch September 13, 2026 10:01
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Sep 13, 2026
…ssion-list-roster-batch-20260913

* commit 'f513c0f345f7f2514c49ccfbc00adc3f78b9a755': (46 commits)
  chore(i18n): refresh native locales (#146924)
  perf(secrets): limit expiry metadata to transient credentials (#146882)
  fix(ui): preserve queued refreshes during session discovery (#146535)
  test(ui): wait for quiet scrolling and close named file tabs (#146836)
  fix(ui): prevent Usage hour filters from freezing during DST (#146919)
  test(ui): share browser page cleanup across layout fixtures (#146805)
  ci: balance complete PR runtime test groups (#146916)
  improve(infra): reduce scheduling work for session notice bursts (#146818)
  improve: prepare Gateway skill commands asynchronously (#146812)
  improve(agents): skip unused assistant delivery parsing (#146858)
  improve(ui): reuse date formatters across timestamp lists (#146789)
  fix(tests): isolate installer and Docker shell snippets (#146897)
  test(heartbeat): share explicit channel configuration fixtures (#146853)
  fix: retain conversation reply claims through write admission (#146866)
  perf(sessions): bound history reads and stabilize cursor paging (#146770)
  fix(ui): let slow dashboard downloads finish before recovery (#146881)
  fix: share Doctor lifecycle coordination with SQLite workers (#146714)
  fix: retain native session model provenance (#146801)
  fix: settle embedded transcript repairs before session cleanup (#146842)
  feat(macos): improve agent navigation and chat layout (#146531)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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