fix(agents): close remaining prompt cache boundary gaps#60691
Conversation
Greptile SummaryThis PR closes three prompt-cache boundary gaps left open after #59054: compaction now flows through the shared Confidence Score: 5/5Safe to merge — all three cache-boundary gaps are correctly closed, tests validate the key seams, and no P0/P1 issues were found. The fix is well-scoped: each affected path (compaction, WS HTTP fallback, later-turn stream reuse) is routed through the boundary-aware transport stack with matching test coverage. The only finding is a P2 style concern ( No files require special attention beyond the minor Prompt To Fix All With AIThis is a comment left during a code review.
Path: src/agents/openai-ws-stream.ts
Line: 90-91
Comment:
**`as never` type cast hiding a model type mismatch**
`createBoundaryAwareStreamFnForModel` likely expects a narrower model type than `Parameters<StreamFn>[0]`, so the cast silences a real type incompatibility rather than a false positive. If the shapes are genuinely compatible, a shared intermediate type (e.g. `ProviderRuntimeModel`) would be safer than `as never` here.
```suggestion
createHttpFallbackStreamFn: (model) =>
createBoundaryAwareStreamFnForModel(model as ProviderRuntimeModel),
```
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "Merge branch 'main' into vk/pr-53225-cac..." | Re-trigger Greptile |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4189946a8b
ℹ️ 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".
* fix(agents): route default stream fallbacks through boundary shapers * fix(agents): close remaining cache boundary gaps * chore(changelog): note cache prefix follow-up rollout * fix(agents): preserve cache-safe fallback stream bases
* fix(agents): route default stream fallbacks through boundary shapers * fix(agents): close remaining cache boundary gaps * chore(changelog): note cache prefix follow-up rollout * fix(agents): preserve cache-safe fallback stream bases
* fix(agents): route default stream fallbacks through boundary shapers * fix(agents): close remaining cache boundary gaps * chore(changelog): note cache prefix follow-up rollout * fix(agents): preserve cache-safe fallback stream bases
* fix(agents): route default stream fallbacks through boundary shapers * fix(agents): close remaining cache boundary gaps * chore(changelog): note cache prefix follow-up rollout * fix(agents): preserve cache-safe fallback stream bases
* fix(agents): route default stream fallbacks through boundary shapers * fix(agents): close remaining cache boundary gaps * chore(changelog): note cache prefix follow-up rollout * fix(agents): preserve cache-safe fallback stream bases
* fix(agents): route default stream fallbacks through boundary shapers * fix(agents): close remaining cache boundary gaps * chore(changelog): note cache prefix follow-up rollout * fix(agents): preserve cache-safe fallback stream bases
Summary
#59054fixed the cache boundary on several transport builders, but three request paths still bypassed that shaping: compaction, OpenAI WS HTTP fallback, and later turns reusing a previously wrapped session stream.<!-- OPENCLAW_CACHE_BOUNDARY -->into provider-visible prompt text or skip the intended Anthropic/OpenAI cache shaping, which risks cache misses and divergent prompt bytes across turns.streamSimple.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
Root Cause (if applicable)
#59054merged before these follow-up path divergences were fully enumerated.Regression Test Plan (if applicable)
src/agents/pi-embedded-runner/run/attempt.test.tssrc/agents/pi-embedded-runner/compact.hooks.test.tssrc/agents/openai-ws-stream.test.tsstreamSimple.User-visible / Behavior Changes
Diagram (if applicable)
Security Impact (required)
Yes, explain risk + mitigation:Repro + Verification
Environment
Steps
Expected
Actual
Evidence
Attach at least one:
Human Verification (required)
createStreamFn, defaultstreamSimplefallback, WS fallback, compaction, later-turn stream wrapper reuse.pnpm buildand targeted Vitest were non-reporting in this environment during the final pass.Review Conversations
Compatibility / Migration
Risks and Mitigations
WeakMap, only used to rebuild from the original base stream, and is resettable in tests.