Fix OpenAI compaction runtime routing#85413
Conversation
|
Codex review: needs real behavior proof before merge. Latest ClawSweeper review: 2026-05-22 17:00 UTC / May 22, 2026, 1:00 PM ET. Workflow note: Future ClawSweeper reviews update this same comment in place. How this review workflow works
Summary Reproducibility: yes. from source inspection, but not from a live oversized compaction run here. Current main routes the preflight gate through local context/reserve threshold math and does not consult the configured OpenAI Responses server-compaction threshold. PR rating Rank-up moves:
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. Real behavior proof Risk before merge
Maintainer options:
Next step before merge Security Review findings
Review detailsBest possible solution: Land only after the production preflight gate honors configured OpenAI Responses server thresholds, focused tests fail on current main and pass on the branch, and redacted real compaction proof confirms Codex OAuth and direct OpenAI API-key routes still behave correctly. Do we have a high-confidence way to reproduce the issue? Yes from source inspection, but not from a live oversized compaction run here. Current main routes the preflight gate through local context/reserve threshold math and does not consult the configured OpenAI Responses server-compaction threshold. Is this the best way to solve the issue? No, not yet. The OpenAI/Codex auth-routing direction looks maintainable, but the patch is incomplete until the production preflight gate uses the configured server threshold and the auth-sensitive path has real proof. Label changes:
Label justifications:
Full review comments:
Overall correctness: patch is incorrect Acceptance criteria:
What I checked:
Likely related people:
Codex review notes: model gpt-5.5, reasoning high; reviewed against a0358bbf1857. |
|
ClawSweeper PR egg 🎁 Pass real behavior proof to wake the egg and unlock a hatchable treat. Where did the egg go?
|
Summary
Root Cause
OpenAI model refs such as
openai/gpt-5.5can run through the Codex harness, but the direct embedded compaction path still mixed raw model provider, selected runtime provider, and context-budget provider decisions. That let budget preflight compaction fall back from stale/missing native Codex thread binding into the context engine, then resolve auth as direct OpenAI API-key mode instead of the selected Codex OAuth route.A second mismatch made the symptom much slower: local preflight compaction used
contextWindow - reserve - softThresholdeven when the model params configured OpenAI Responses server compaction at a higher threshold. In the observed local setup that caused preflight compaction around the mid-100k token range even though the configured server threshold was 200k, so Telegram ingress worked but replies appeared stuck before normal inference.RCA proof:
No_API_key_found_for_provider_openaion the compaction path.src/agents/pi-embedded-runner/compact.tsresolved compaction model/auth before consistently applying the selected OpenAI runtime provider, and its context-window lookup could use the current policy runtime instead of the persisted session runtime.src/auto-reply/reply/agent-runner-memory.tspreflight gating ignoredresponsesServerCompaction/responsesCompactThresholdmodel params when deciding whether to run local compaction.Real behavior proof
Behavior addressed: OpenAI GPT-5.5 compaction under Codex OAuth no longer asks for direct OpenAI API-key auth, direct OpenAI API-key configurations are preserved, and local preflight compaction waits for the configured server threshold instead of blocking replies early.
Real environment tested: local OpenClaw checkout and managed gateway on Linux, Node 25.9.0, configured default model
openai/gpt-5.5with Codex runtime/OAuth.Exact steps or command run after this patch:
node scripts/run-vitest.mjs src/agents/openai-codex-routing.test.ts src/agents/pi-embedded-runner/compact.hooks.test.ts src/auto-reply/reply/agent-runner-memory.test.ts;pnpm build;oc-update --skip-codex;pnpm openclaw status --all.Evidence after fix: focused Vitest reported
Test Files 4 passed (4)andTests 131 passed (131); build completed successfully;oc-update --skip-codexrebuilt core/UI, reinstalled the daemon, and health check passed on retry; status reported TelegramOKand the gateway reachable.Observed result after fix: the compaction unit path routes configured Codex OAuth sessions through
openai-codex, keeps API-key-only OpenAI sessions onopenai, uses the persisted Codex runtime for context-window sizing, and skips local preflight compaction below the configured OpenAI Responses server threshold.What was not tested: no new live Telegram message was sent through the production topic after the patch; live status confirms Telegram/gateway readiness, while behavior proof is targeted unit coverage plus local build/update/status.
Verification
node scripts/run-vitest.mjs src/agents/openai-codex-routing.test.ts src/agents/pi-embedded-runner/compact.hooks.test.ts src/auto-reply/reply/agent-runner-memory.test.tspnpm build.agents/skills/autoreview/scripts/autoreview --mode branch --base origin/mainfound two accepted P2 issues; both were patched and covered by regression tests. Per user request, no further autoreview was run after the final API-key preservation patch.oc-update --skip-codexpnpm openclaw status --all