Repository navigation
fix(openai): restore cache-TTL context pruning - #127992
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 50e697f56a
ℹ️ 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".
|
Codex review: needs real behavior proof before merge. Reviewed September 20, 2026, 12:16 AM ET / 04:16 UTC (Revision 10). ClawSweeper reviewWhat this changesThe PR enables configured idle-time pruning of old OpenAI tool results using resolved endpoint and cache capability facts, with proxy opt-in, explicit opt-out, tests, and SDK documentation. Merge readiness⛔ Blocked before merge - 4 items remain This remains useful work: current main and the latest release still lack OpenAI eligibility. Earlier proxy and OAuth findings are resolved; the public-contract decision and inspectable runtime evidence remain outstanding. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw’s embedded runner uses provider eligibility and configured idle time to decide whether old tool results should be shortened before model requests. Existing session markers preserve those projected results across later turns and restarts. flowchart TD
A[Resolved model and pruning settings] --> B[OpenAI route eligibility]
B --> C[Idle and context-size checks]
C --> D[Projected tool results]
D --> E[Model request]
B --> F[Session cache marker]
F --> D
Decision needed
Why: The discussion explicitly requests this contract decision, and current behavior does not establish previously supported OpenAI pruning. Before merge
Agent review detailsSecurityNone. PR surfaceSource +36, Tests +203, Docs +1. Total +240 across 11 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Approve a bounded provider-owned eligibility contract that preserves proxy opt-outs, configured TTLs, original transcripts, and stable replay through the existing pruning owner. Do we have a high-confidence way to reproduce the issue? Yes, at source level: an OpenAI embedded session with cache-ttl configured fails the current eligibility gate. This establishes the exclusion, not a historical regression; no runtime execution was performed during this review. Is this the best way to solve the issue? Yes, the existing provider hook is the narrowest implementation path; adding a separate pruning mode would duplicate ownership. Acceptance of the expanded support contract remains a maintainer choice. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against ad3fc06d6411. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (9 earlier review cycles; latest 8 shown)
|
|
Hi maintainers — could you please rerun the failed CI jobs for exact head The only primary failure is Thank you. |
|
Addressed the current OAuth route finding in
The PR body now carries the updated route matrix, cumulative LOC, validation, and the unchanged credentialed-live-proof limitation. No direct OpenAI or ChatGPT/Codex OAuth credential was available, so no live call is claimed. |
|
Hi @steipete — when you have a chance, could you please review this PR’s OpenAI/ChatGPT prompt-cache-key TTL handling and let me know if any changes are needed or if it is ready to merge? Thanks! |
|
Hi @vincentkoc — this PR is still ready for review, and there have been no maintainer updates since my last follow-up. When you have a chance, could you please take a look and let me know whether it can be merged or if anything else is needed? Thank you. |
|
Hi @vincentkoc, when you have a chance, could you please take another look and let me know whether this is ready to merge or needs any changes? Thank you. |
|
Updated exact head Validation on the merged result: 4 Vitest shards / 6 files / 138 tests passed; the targeted |
|
Hi @vincentkoc, when you have a chance, could you please check the proposed provider-hook contract and advise what remains before merge? The real provider-session proof is still unavailable, as disclosed in the PR. Thank you. |
|
Hi @vincentkoc, could you please check whether the optional |
|
Hi @steipete, could you please check whether the optional |
|
Hi @steipete, when you have a chance, could you please check the optional |
|
This assigned pull request has been automatically marked as stale after being open for 27 days. |
Preserve the contributor branch and retained main merge while carrying the source-bound route eligibility repair, regression tests, and SDK documentation.
* fix(openai): enable cache-TTL context pruning * fix(openai): gate cache ttl by resolved route * fix(openai): include OAuth route in cache ttl * test(agents): align cache ttl coverage with projection state
Closes #95840
What Problem This Solves
Fixes stale tool results remaining in OpenAI requests after the configured cache-TTL idle gap.
User Impact
Official OpenAI routes can prune expired tool-result context when
contextPruning.modeiscache-ttl. Explicit opt-out remains authoritative; custom proxy routes remain unchanged unless explicitly opted in withcompat.supportsPromptCacheKey: true.Why This Change Was Made
The provider eligibility hook receives the same bounded route and capability facts for pruning setup and cache-touch recording. It does not receive the full model, headers, or extra request parameters. The repair preserves original contributor ancestry and keeps the existing Anthropic/Google behavior.
Evidence
42dcea5312ff. Final documentation and timeout-test additions also passed exact-tree formatting, affected native typechecking, and targeted lint.e0e6ce7bab919a9e37079841b6ee399cb90631b8. Later main drift has been mapped separately; runtime evidence is bound to the qualified tree, not claimed as rerun on an untested whole tree.No live Codex/OAuth-service acceptance, provider cache hit, or billing savings is claimed. Offline response simulation is distinct from the four real API routes.
Original contribution: Daniel Peng (@original4422); contributor commit ancestry is preserved.
AI-assisted: yes — implementation, qualification, and independent API review used Codex.
Inspectable runtime evidence
Qualified production tree:
ffaf1aa28b5005f0d11bb070d85389a281c1d9b1(integrated main42dcea5312ff). Published head29e7d34c281358d1f77acd6ad175684af5b9a642has that identical tree; the publication commits only preserve contributor/main ancestry. These are excerpts from the existing source-bound run journals, not newly executed calls.The task-private fixture ran the real
runEmbeddedAgent, production provider registration/serialization, supported exec SecretRef resolution, and durable SQLite session reload. It seeded synthetic old/fresh tool outputs into an existing session, withcontextPruning: { mode: "cache-ttl", ttl: "250ms" }. Each replay phase started a fresh process. The four live lanes used Platform Responses (gpt-4.1-mini); the proxy really forwarded to Platform.The table is computed from actual
requests[0].body.input[].outputstrings and persisted custom entries, not the journal's pass flags.6377is the complete synthetic old tool result;3086is its real trimmed request projection. Every phase retained the exact fresh outputSYNTHETIC_FRESH_PR127992, and every durable source transcript still containedSYNTHETIC_OLD_MIDDLE_PR127992.Literal Platform projection / durable-marker excerpt
Repeated
alpha/betafiller is omitted below and marked as an excerpt. The trimming annotation and fresh output are literal transport-body strings. No auth, private endpoints, local paths, request instructions or personal data are included.Real-route counterexamples and baseline
req_c4c67900b3e9463d9c32bb614704af84req_89ab61018a354d0c98c37582d015b46creq_8d1a8852a9414b08ab35493922378c6breq_1eed7becef1f4468af6da9f57a991e56req_6287b4cea1454b8c8bc01a588af977e6The baseline replaced only the eligibility helper with its exact original bytes from
aac3b2773c7f, used the same real runner and service, and retained the old middle after the TTL gap with no cache touches. The expected after-idle assertion failed; the exact candidate helper was restored infinally. No baseline or diagnostic call is omitted from the 23-request cumulative total.Provenance and limits
openaiowner, actual production request construction and both changed consumers, with synthetic auth and all network egress blocked. The local service response was simulated. Native zstd codec input/output and actual compressed fetch bytes were captured independently; hashes, decoded bodies and eight adverse mutation controls were verified. This is not live Codex/OAuth service evidence.Journal SHA-256 bindings for the excerpts
Maintainer contract and upgrade disposition
Accepted for this scoped repair: add the two optional, bounded provider-hook facts (
baseUrlandsupportsPromptCacheKey) and enable the existing configured cache-TTL behavior for eligible official OpenAI embedded routes. The existing provider hook is the owner; no new pruning mode, configuration option, default, transcript format, or retention policy is introduced.This is an intentional support expansion, not a claim that released OpenAI pruning already worked. An existing global
contextPruning.mode: "cache-ttl"configuration (including an earlier seeded configuration) can now shorten eligible OpenAI tool-result request projections after the configured idle/size thresholds. Original transcript entries remain intact, as the persisted-source checks above verify. ExplicitsupportsPromptCacheKey: falseremains authoritative, custom proxies stay ineligible without explicittrue, and disabled-pruning, compaction/timeout, Anthropic/Google and fresh-output controls remain covered.The compatible hook extension and this bounded upgrade effect are the selected implementation disposition for the assigned repair-and-land work. No live Codex/OAuth service acceptance is inferred from the offline lane.