← Back to Pull requests

fix: do not store a store=false continuation of a stored response #387

Merged
StevenWang-CY merged 5 files (263 lines) on Sep 27, 2026 22:06 UTC
View on GitHub
StevenWang-CY StevenWang-CY commented on Sep 27, 2026 13:34 UTC
Author

Summary

should_persist in executor/persist.rs treated previous_response_id as a reason to write. On the no-session HTTP path a store: false request that continued a stored response was therefore persisted durably as a row without a snapshot. The id it returned resolved as previous_response_id on the next request, and GET /v1/responses/{id} answered 409 no retrievable payload instead of 404. ADR-02, TERMINOLOGY.md and the README all state that store: false disables durable response storage, and the guarding test is named ..._hydrates_but_does_not_persist. #257 fixed the same contract for WebSocket sessions and explicitly left the no-session HTTP policy unchanged, so this is the HTTP half of #238.

The fix drops the previous_response_id term, so store governs the no-session path. The child is still hydrated from the stored parent and answers normally; it just leaves no row, so its id can be neither retrieved nor continued, which is the OpenAI behavior for store: false. Nothing else changes:

  • Session continuations still reach the handler through continuation.is_some(), which keeps store: false checkpoints connection-local (#257).

  • Explicit conversation_id requests stay durable.

  • WebSocket generate: false prewarm calls persist_turn directly and never consulted this predicate.

  • The predicate gates every write: persist_if_needed, shared by the JSON, SSE and split-execution commit paths, and the public persist_response/persist_turn steps of ADR-03, so a consumer composing the steps gets the same contract as execute.
  • docs/api/index.md states the contract next to the routing rule, and ARCHITECTURE.md notes it on the persist.rs entry.

    Test Plan

    Red on unmodified main (280f798), green with this change, with only the test files applied to a worktree at main and the workspace crates rebuilt from that worktree:

  • test_store_false_with_previous_response_id_hydrates_but_does_not_persist passed on main for the wrong reason: the mock queue held two replies, so the third continuation failed from queue exhaustion, not from a missing response. It now queues a third reply, asserts the continuation fails with the storage not-found error before any inference runs, and continues the stored parent as a control that consumes that third reply. On main the continuation succeeds.

  • New store_false_continuation_of_a_stored_response_is_not_retained drives the gateway over HTTP: a stored parent, a store: false child that the upstream request shows was hydrated from it, then GET of the child and a continuation from it both answer 404 with no upstream call, while the parent is still retrieved byte-for-byte and continued. On main the GET answers 409 and the continuation succeeds.

  • New test_public_persist_steps_honor_the_storage_policy drives rehydrate_conversation, persist_response and persist_turn directly for a store: false and a store: true continuation of a stored parent and checks whether each produced id resolves as previous_response_id. On main both store: false ids resolve.

  • Against the agentic-server binary built from this commit, with a stdlib mock upstream and a SQLite file: the same sequence through the real HTTP stack ends with the responses table holding the parent and the stored sibling only, and both misses answer 404 not_found.

  • pre-commit run --all-files (including rust-file-sizes with RUST_FILE_SIZE_BASE=origin/main), cargo fmt -- --check, cargo clippy --all-targets -- -D warnings, and cargo test --no-fail-fast across the workspace pass on the exact commit from a clean worktree.
  • Diff: 263 lines (+236 / -27) across 5 files Reviewer: franciscojavierarceo Review duration: 512m
    All Vouch review confidence checks passed
    Residual risk 0.07 = Change Risk (0.47) × (1 − Review Confidence (0.84)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.47 · 263 lines diff across 5 files
    0.47
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.77 · 3 substantive comment(s)
    0.77
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    84%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.334
    Ai Authored ai_authored
    0.050
    Real PR Conversation Timeline
    6 items
    Copilot Copilot commented on code on Sep 27, 2026 15:26 UTC
    Code Review
    crates/agentic-server-core/src/executor/persist.rs:1
    @@ -16,12 +16,16 @@ use crate::types::io::{InputItem, OutputItem};
     use crate::types::request_response::ResponsePayload;
     use tracing::error;
     
    +/// Decides whether a completed turn reaches the storage handlers.
    +///
    +/// `store` governs the no-session path: a `store: false` request leaves no row
    +/// even when `previous_response_id` hydrated it from a stored response, so its
    +/// id can be neither retrieved nor continued. Session continuations always reach
    +/// the handler, which keeps `store: false` checkpoints connection-local. An
    +/// explicit conversation stays durable.
     #[must_use]
     pub(crate) fn should_persist(ctx: &RequestContext) -> bool {
    -    ctx.continuation.is_some()
    -        || ctx.original_request.store
    -        || ctx.original_request.previous_response_id.is_some()
    -        || ctx.original_request.conversation_id.is_some()
    +    ctx.continuation.is_some() || ctx.original_request.store || ctx.original_request.conversation_id.is_some()

    This predicate is not the only exported persistence entrypoint: persist_response is re-exported from executor/mod.rs and directly calls persist_prepared_response without consulting should_persist. A consumer composing the documented public executor steps can still pass a no-session store: false context with previous_response_id and create the very durable row this change claims to forbid. Apply the same policy in persist_response (or make that API explicitly bypass request storage semantics) so the contract is consistent for all public paths.

    copilot-pull-request-reviewer[bot] copilot-pull-request-reviewer[bot] commented on Sep 27, 2026 15:26 UTC
    Reviewer

    <!-- ccr-overview-v2 -->

    Copilot review overview

    🟡 Changes recommended

    The public persist_response path can still persist a no-session store: false continuation.

    Review effort: Lite
    Findings: 1 <picture><source media="(prefers-color-scheme: dark)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/high-v2-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/high-v2-light.svg"><img src="https://github.githubassets.com/static/images/icons/copilot-code-review/high-v2-light.png" alt="High severity" width="62" height="18" align="texttop"></picture>

    <details open>
    <summary><strong>Open (1)</strong></summary>

  • <picture><source media="(prefers-color-scheme: dark)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/high-v2-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/high-v2-light.svg"><img src="https://github.githubassets.com/static/images/icons/copilot-code-review/high-v2-light.png" alt="High severity" width="62" height="18" align="texttop"></picture> [Enforce should_persist policy in re-exported persist_response](#discussion_r4115900852) · New

  • </details>

    <details>
    <summary><strong>What changed in this PR</strong></summary>

    Fixes HTTP store: false continuations so they hydrate stored history without creating durable response rows. A critical consistency issue remains in the public persist_response path.

    Changes:

  • Updates persistence gating.

  • Adds core and HTTP regression coverage.

  • Documents the storage contract.
  • | File | Summary |
    |---|---|
    | docs/​api/​index.md | Documents unstored continuation behavior. |
    | crates/​agentic-server/​tests/​response_retrieval_test.rs | Tests HTTP retrieval and continuation failures. |
    | crates/​agentic-server-core/​tests/​stateful_responses_integration.rs | Verifies hydration without persistence. |
    | crates/​agentic-server-core/​src/​executor/​persist.rs | Updates persistence eligibility. |
    </details>

    ---

    💡 <a href="/vllm-project/agentic-api/new/main?filename=.github/skills/code-review/SKILL.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add a code-review agent skill</a> or configure MCP servers for context-aware, tailored reviews. <a href="https://docs.github.com/copilot/how-tos/use-copilot-agents/request-a-code-review/use-code-review?tool=webui#mcp-servers-and-agent-skills" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn more in the docs.</a>

    StevenWang-CY StevenWang-CY commented on code on Sep 27, 2026 15:38 UTC
    Code Review
    crates/agentic-server-core/src/executor/persist.rs:1
    @@ -16,12 +16,16 @@ use crate::types::io::{InputItem, OutputItem};
     use crate::types::request_response::ResponsePayload;
     use tracing::error;
     
    +/// Decides whether a completed turn reaches the storage handlers.
    +///
    +/// `store` governs the no-session path: a `store: false` request leaves no row
    +/// even when `previous_response_id` hydrated it from a stored response, so its
    +/// id can be neither retrieved nor continued. Session continuations always reach
    +/// the handler, which keeps `store: false` checkpoints connection-local. An
    +/// explicit conversation stays durable.
     #[must_use]
     pub(crate) fn should_persist(ctx: &RequestContext) -> bool {
    -    ctx.continuation.is_some()
    -        || ctx.original_request.store
    -        || ctx.original_request.previous_response_id.is_some()
    -        || ctx.original_request.conversation_id.is_some()
    +    ctx.continuation.is_some() || ctx.original_request.store || ctx.original_request.conversation_id.is_some()

    Valid, thanks. persist_response and persist_turn wrote unconditionally, so the composable steps disagreed with execute and commit. Both public steps now return early when should_persist is false (6dca512); session contexts still reach their handler, so WebSocket generate: false prewarm is unchanged. test_public_persist_steps_honor_the_storage_policy drives rehydrate_conversation → persist_response / persist_turn for store: false and store: true continuations and checks whether the id resolves as previous_response_id; on main both store: false ids resolve.

    StevenWang-CY StevenWang-CY commented on Sep 27, 2026 20:21 UTC
    Author

    @franciscojavierarceo when you have a moment, could you take a look? CI is green and the Copilot finding is addressed in 6dca512.

    franciscojavierarceo franciscojavierarceo approved these changes on Sep 27, 2026 22:06 UTC
    Approved Reviewer

    Approved these changes.

    Assignees
    StevenWang-CY StevenWang-CY
    Labels
    risk: low confidence: 84.3% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 47.2% (MEDIUM) · Higher = larger blast radius
    47.2%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 84.3% · Lower = rushed or shallow review
    84.3%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 7.4% · Safe to merge
    7.4%