Repository navigation
fix(agents): preserve prompt cache boundary keys - #126380
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 19, 2026, 1:46 PM ET / 17:46 UTC. ClawSweeper reviewWhat this changesThe PR preserves reset and compaction boundary suffixes when long session IDs are converted into OpenAI-compatible prompt-cache keys. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readinessKeep open. This maintainer-authored, maintainer-labeled PR fixes a current-main collision at the derivation owner; no blocking patch defect was found. Priority: P2 Review scores
Verification
Live VerificationCommand: Result: FAIL (partial) — step 2 Assertions:
How this fits togetherThe embedded agent runner derives a cache key from a session ID and lifecycle boundary, then passes it through provider request builders. OpenAI-compatible builders cap that key at 64 Unicode code points before sending it upstream. flowchart LR
A[Session ID] --> C[Cache-key derivation]
B[Reset or compaction count] --> C
C --> D[OpenAI-compatible key]
D --> E[Provider request builder]
E --> F[Length-limited upstream key]
Before merge
Agent review detailsSecurityNone. PR surfaceSource 0, Tests +9. Total +9 across 2 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Retain this derivation-owner repair so long internal session IDs preserve distinct reset and compaction cache boundaries without adding a second provider-side policy. Do we have a high-confidence way to reproduce the issue? Yes — source inspection provides a high-confidence deterministic path: use a session ID longer than 64 Unicode code points and boundary counts 0, 1, and 2; current main truncates all suffixes away. Is this the best way to solve the issue? Yes — reserving the suffix within the derivation owner’s existing provider limit is narrower and safer than relying on downstream request builders after the lifecycle distinction has already been lost. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against e474d23e653c. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Land-ready proof for
Explicit caller keys, short derived keys, and non-OpenAI APIs remain unchanged. No compatibility path, fallback, schema change, protocol change, or removed runtime path is involved. |
|
Merged via squash.
|
What Problem This Solves
Fixes an issue where OpenAI-backed sessions with long internally derived session IDs could reuse the same prompt-cache key after a reset or compaction. The lifecycle boundary suffix was appended after the session ID and then truncated away at the 64-code-point provider limit, so distinct boundaries collided.
Why This Change Was Made
Derived keys now reserve space for
:<boundaryCount>inside the canonical OpenAI prompt-cache-key limit and truncate only the session ID using Unicode code-point semantics. Explicit caller-provided keys, short derived keys, and non-OpenAI APIs keep their existing behavior.This is the canonical derivation-owner repair: no fallback or downstream guard was added. Production LOC is +5/-5 (net zero); tests are +22/-13.
User Impact
Reset and compaction boundaries retain distinct prompt-cache affinity even for long internal session IDs, preventing stale boundary collisions while keeping normal short-session behavior unchanged.
Release-note context: OpenAI prompt-cache keys now preserve reset and compaction boundaries for long session IDs.
Evidence
31a1dca82acee7304a76b6dab73191d460555949e474d23e653c91fb3364976f6ecd8fb61b4cf0f5node scripts/run-vitest.mjs src/agents/embedded-agent-runner/run/session-boundary-prompt-cache-key.test.ts— 1 file, 3/3 tests passed.node scripts/check-changed.mjs—coreandcoreTestspassed.node_modules/.bin/oxfmt --check src/agents/embedded-agent-runner/run/session-boundary-prompt-cache-key.ts src/agents/embedded-agent-runner/run/session-boundary-prompt-cache-key.test.ts— passed.git diff --check origin/main...HEAD— passed.