Repository navigation
fix: forward prompt_cache_key in standalone compaction - #412
Merged
maralbahari merged 1 commit intoOct 2, 2026
Merged
Conversation
Signed-off-by: zitian zhao <[email protected]>
skyloevil
marked this pull request as ready for review
October 1, 2026 19:31
skyloevil
requested review from
bbrowning,
franciscojavierarceo,
haoshan98,
jiahuei,
leseb,
maralbahari,
noobHappylife,
qandrew and
tjtanaa
as code owners
October 1, 2026 19:31
skyloevil
marked this pull request as draft
October 1, 2026 19:36
skyloevil
marked this pull request as ready for review
October 1, 2026 21:38
maralbahari
approved these changes
Oct 2, 2026
haoshan98
added a commit
that referenced
this pull request
Oct 5, 2026
## Summary `prompt_cache_retention` survives raw HTTP pass-through today, but is dropped when storage, continuation, or built-in tools route a request through typed execution. Preserve the legacy `in_memory` and `24h` values through that path, including tool rounds, multi-agent execution, and compaction. OpenAI defines `prompt_cache_retention` as the prompt-cache retention policy: `in_memory` selects in-memory retention, while `24h` selects extended retention up to 24 hours, where supported. This is distinct from storing Responses history and from `prompt_cache_options.ttl`, which expresses a minimum cache lifetime. Available policies depend on the upstream model; this PR preserves the requested value without implementing retention or guaranteeing cache reuse. See the [OpenAI prompt caching guide](https://developers.openai.com/api/docs/guides/prompt-caching). - Validate the two wire values on HTTP and WebSocket entry points and expose them in OpenAPI. - Keep retention request-scoped: restoring history does not inherit the parent's policy. Typed execution omits absent/null values; raw HTTP keeps an explicit null. - Document upstream support limits. Forwarding does not implement cache lifetime or guarantee backend support; capability enforcement and `prompt_cache_options` remain separate work. Part of #330. Includes the standalone compaction cache-key forwarding from #412, now merged into main. Wire values checked against [openai-python](https://github.com/openai/openai-python/blob/10f88169b0f3929b4e2528aad7a825df31163156/src/openai/types/responses/response_create_params.py). ## Test Plan After merging main at `f591cee` and resolving the overlapping compaction fields and appended tests: - `cargo test --locked -p agentic-server-core --lib compaction` — 49 passed. - `cargo test --locked -p agentic-server --test compaction_test --test responses_test --test responses_websocket_test` — 140 passed. - `cargo test --locked -p agentic-server --features openapi --test openapi_test` — 9 passed. - `cargo clippy --locked --all-targets -- -D warnings` and `pre-commit run --all-files` — passed. The initial implementation also passed the core unit suite and web-search tool-round suite. Tests capture upstream requests for JSON/SSE parity, invalid values rejected before inference, SQLite continuation omission/null/override, every tool round, and compaction snapshots. They verify request preservation rather than cache hits against a live model. Signed-off-by: zitian zhao <[email protected]> Co-authored-by: Hao Shan <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Standalone
/v1/responses/compactcurrently acceptsprompt_cache_keyas an unmodeled compatibility field and drops it before summary inference. Type the field and forward it through the existing compaction path.The key remains request-scoped: omitted or null values are not inherited from
previous_response_id. Invalid types return 400 before inference. Update the API docs to include the standalone endpoint.Part of #330. Follows #347 and #389.
Test Plan
cargo test --offline -p agentic-server --test compaction_test --quiet— 11 passed, including explicit/empty, omitted/null, invalid, and stored-history cache-key cases.cargo test --offline -p agentic-server --test openapi_test --quietcargo clippy --offline --all-targets -- -D warnings