Skip to content

refactor(ai): keep model policy parsing independent of transport host - #142804

Merged
steipete merged 1 commit into
mainfrom
codex/provider-policy-number-leaf
Sep 9, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/provider-policy-number-leaf

Conversation

@steipete

@steipete steipete commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Related: #142682, #142738

What Problem This Solves

Resolves a problem where reading OpenAI model policy pulls in the AI transport host solely to parse a positive integer. The unnecessary dependency was found while investigating cold first-reply Signal test failures.

Why This Change Was Made

Move the exact existing parser into a private leaf module and have Responses payload policy import that leaf. The old transport-utils export remains available. An import-boundary regression prevents model-policy loading from depending on the transport host again.

User Impact

Model-policy inspection has a narrower dependency graph. Fast choices, model routes, numeric coercion, and existing public exports retain their behavior. No package exports, dependencies, versions, or configuration change.

Evidence

The import-boundary test failed on the original graph and passes after the change. The canonical five-path gate, ordinary build, and independent Codex review passed. Sixty-six focused tests cover the import boundary, Fast and route policy, Responses handling, and coercion. Rebuilt AI package exports and four native threshold cases also passed.

The original Signal CI shard passed on Linux with fresh caches and three workers: 48 files and 863 tests, without changing its assertions, timeouts, fixtures, or routing. The previously failing prefix case took 4.228 seconds; the cancellation case took 0.447 seconds. All temporary profiling changes were removed.

A causal comparison confirmed that the earlier Fast metadata import increased cold source-loader work. This patch removes a verified transport-host dependency, but residual source-test startup cost remains; these measurements do not establish a production latency improvement. The remote test runtime was Node 24.19, while the original CI failure used Node 24.20; the failure was also reproduced independently on the remote runtime.

@clawsweeper

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

@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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 9, 2026
@steipete
steipete marked this pull request as ready for review September 9, 2026 03:36
@clawsweeper

clawsweeper Bot commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 8, 2026, 11:41 PM ET / September 9, 2026, 03:41 UTC (Revision 2).

ClawSweeper review

What this changes

Moves numeric parsing into a lightweight internal module so OpenAI model-policy inspection avoids loading the transport host, while preserving existing exports and adding regression coverage.

Merge readiness

✅ Ready for maintainer review

This remains a useful, focused refactor: current main still has the unwanted dependency, and the patch preserves existing parsing behavior. No actionable correctness or security findings were identified.

Priority: P3
Reviewed head: 197cc3bb4136f9296459747b1dd64fa1d03fb2a6

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, compatible extraction with useful regression coverage and no identified blocking defects.
Proof confidence 🌊 off-meta tidepool Not applicable: The maintainer-authored internal refactor is exempt from the external-contributor proof gate. Reported import-boundary, build, threshold, and Linux shard checks support the changed path without establishing production latency gains.
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 internal refactor is exempt from the external-contributor proof gate. Reported import-boundary, build, threshold, and Linux shard checks support the changed path without establishing production latency gains.
Evidence reviewed 8 items Parser behavior and existing imports preserved: The introduced diff moves the parser body unchanged and re-exports it from transport-utils. Existing Anthropic callers continue using that export; Responses policy imports the new leaf directly.
Current main still needs the change: The fetched main revision still imports parsePositiveInteger from transport-utils, which imports the AI transport host.
Latest release retains the old dependency: The supplied latest release, v2026.9.3, also imports the parser through transport-utils; it does not contain this extraction.
Findings None None.
Security None None.

How this fits together

OpenAI model policy uses model metadata and request parameters to determine supported request options and compaction thresholds. Its metadata readers share this policy with request construction, so their imports affect how much runtime code loads during inspection.

flowchart LR
  A[Model metadata and parameters] --> B[OpenAI model policy]
  B --> C[Responses payload policy]
  C --> D[Standalone integer parser]
  C --> E[Capabilities and thresholds]
  E --> F[Request construction]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +1, Tests +32. Total +33 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 3 10 9 +1
Tests 2 32 0 +32
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 42 9 +33

Review metrics

None.

Technical review

Best possible solution:

Keep one shared parser behind a lightweight leaf import, preserving numeric coercion and existing caller exports.

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

Yes for the import dependency: current main's metadata path reaches the transport host through the integer parser. Signal timing failures were not independently reproduced in this read-only review.

Is this the best way to solve the issue?

Yes. Moving the unchanged parser and preserving its existing export removes the dependency without duplicating policy or changing request semantics.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P3: This is a behavior-preserving dependency cleanup with focused architecture and coercion coverage.
  • 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 internal refactor is exempt from the external-contributor proof gate. Reported import-boundary, build, threshold, and Linux shard checks support the changed path without establishing production latency gains.

Evidence

What I checked:

  • Parser behavior and existing imports preserved: The introduced diff moves the parser body unchanged and re-exports it from transport-utils. Existing Anthropic callers continue using that export; Responses policy imports the new leaf directly. (packages/ai/src/transports/positive-integer.ts:3, 197cc3bb4136)
  • Current main still needs the change: The fetched main revision still imports parsePositiveInteger from transport-utils, which imports the AI transport host. (packages/ai/src/transports/openai-responses-payload-policy.ts:13, 3f0f98ef7efe)
  • Latest release retains the old dependency: The supplied latest release, v2026.9.3, also imports the parser through transport-utils; it does not contain this extraction. (packages/ai/src/transports/openai-responses-payload-policy.ts:13, 1391f7cd2d40)
  • Relevant implementation boundary: The metadata facade reaches OpenClaw's Responses policy through openai-fast-mode and the existing AI package subpath. The changed integer parsing and import boundary do not depend on a Codex harness or protocol contract. (src/llm/providers/openai-fast-mode.ts:1, 197cc3bb4136)
  • Meaningful architecture regression guard: The added test checks the provider-policy entrypoint for a transitive host dependency. Its existing helper resolves workspace aliases and traverses runtime imports while excluding type-only imports; the additional threshold cases exercise the production compaction-plan boundary. (extensions/openai/model-construction.imports.test.ts:5, 197cc3bb4136)
  • Captured validation and review continuity: The supplied complete PR body reports a failing-before/passing-after import guard, 66 focused tests, package/build checks, and a fresh-cache Linux Signal shard with 863 passing tests. It explicitly disclaims demonstrated production latency improvement. The previous review covered the same head and retained no findings. These execution reports were not independently rerun during this read-only review. (197cc3bb4136)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • obviyus: 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 (1 earlier review cycle)
  • reviewed 2026-09-09T03:35:48.584Z sha 197cc3b :: needs maintainer review before merge. :: none

@steipete
steipete merged commit b74002f into main Sep 9, 2026
218 checks passed
@steipete
steipete deleted the codex/provider-policy-number-leaf branch September 9, 2026 04:49
@steipete

steipete commented Sep 9, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit to LiuwqGit/openclaw that referenced this pull request Sep 9, 2026
…1-prep

* commit 'b04a3f83adad8bd6a2ca8408e7940fc6bcbde212': (636 commits)
  docs(cli): split the doctor command reference by reader job (openclaw#142855)
  fix(ui): explain paused weekly skill reviews (openclaw#142840)
  docs(automations): describe supported schedule options (openclaw#135964)
  fix(image): close registration resources after generation (openclaw#142843)
  fix(slack): keep ack reactions independent of status reactions (openclaw#142595)
  fix(ui): avoid flashes when switching cold sessions (openclaw#134868)
  refactor(tests): share independent no-queued-reply expectations (openclaw#142845)
  perf: reduce generated media reference formatting overhead (openclaw#142836)
  fix: sessions_yield keeps long transcript history available (openclaw#137381)
  fix(music): close registration resources after generation (openclaw#142834)
  fix: update confirmation shows stale commit counts after refresh (openclaw#142837)
  fix(ci): retain Android emulator post-timeout evidence (openclaw#142835)
  fix(talk): retain final delivery across delegation waves (openclaw#142830)
  docs(gateway): run Linux system services as the state owner (openclaw#136266)
  fix(models): align static Anthropic aliases with manifest (openclaw#137376)
  test(gateway): simplify session lifecycle gates and report early rollback failures (openclaw#142833)
  refactor(ai): keep model policy parsing independent of transport host (openclaw#142804)
  refactor: simplify interactive SDK forwarding (openclaw#142824)
  fix(cli): finish pending cleanup before automatic macOS exit (openclaw#142814)
  docs(memory-lancedb): clarify enforced compatibility ranges (openclaw#142827)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: openai maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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