LCORE-1573: surface compaction outcome as context_status in query responses - #2443
LCORE-1573: surface compaction outcome as context_status in query responses#2443max-svistunov wants to merge 2 commits into
Conversation
|
Warning Review limit reached
Next review available in: 7 minutes Limit details: You’ve used all 1 included review currently available under your plan. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (15)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…ponses
Add a context_status field ("full" when no compaction occurred,
"summarized" when older turns were replaced by a compaction summary) to
the two response surfaces clients actually receive on the wire:
- QueryResponse (src/models/api/responses/successful/query.py) for the
non-streaming /v1/query endpoint.
- EndEventData (src/models/common/agents/stream_payloads.py), the SSE
"end" event payload, for the streaming /v1/streaming_query endpoint.
StreamingQueryResponse is a documentation-only class with an empty
body, so the field is deliberately NOT added there; only its SSE
example string is updated to show context_status in the end event.
The value maps directly from CompactionResult.compacted (set by the
LCORE-1572 compaction integration): a new context_status property on
CompactionResult performs the mapping in one place. The non-streaming
endpoint reads it when building QueryResponse; the streaming
compaction-aware path captures it from the yielded CompactionResult and
threads it through generate_agent_response (new context_status
parameter, defaulting to "full" for the non-compaction path) into
EndStreamPayload.create.
The shared ContextStatus Literal["full", "summarized"] type alias lives
in models/common/turn_summary.py (imported by both response surfaces
already) and is exported from models.common. In the regenerated OpenAPI
schema it becomes a named enum component referenced by
QueryResponse.context_status; the streaming endpoint's SSE example now
shows context_status in the end event (the streaming response is
documented via an inline example only, so EndEventData itself does not
appear as a component schema).
/v1/responses intentionally does not get the field (it stays
OpenAI-shaped and compacts silently by design, R12), and the A2A
executor is out of scope for the UI-indicator use case.
Unit tests cover the CompactionResult mapping, the QueryResponse field
(default, explicit value, rejection of unknown values), the end event
payload contents for both statuses, and the full/summarized threading
through both endpoint pipelines.
…n doc Update the conversation-compaction design doc to match the implemented context_status surface: - Rewrite the "API response changes" section: the field is added to QueryResponse (non-streaming /v1/query) and EndEventData (the streaming SSE end event payload), not to StreamingQueryResponse, which turned out to be a documentation-only class with an empty body — adding a field there would change nothing on the wire, so it is intentionally skipped and only its SSE example is updated. - Replace the stale "src/models/responses.py (now relocated)" row in the key-files table with the two real locations and the docs-only-skip note. - Update the request-flow step 11 note now that LCORE-1573 has landed.
f6b5bbb to
a3cc753
Compare
Description
Add a
context_statusfield ("full"/"summarized") to query responses so clients know whether conversation compaction occurred (LCORE-1573, part of the conversation-compaction feature, LCORE-1631 epic).The field is added in the two places clients actually receive on the wire:
QueryResponse(src/models/api/responses/successful/query.py) — the non-streaming/v1/queryresponse body.EndEventData(src/models/common/agents/stream_payloads.py) — the SSEendevent payload for/v1/streaming_query, alongside the analogoustruncatedsignal.StreamingQueryResponseis a documentation-only class with an empty body, so the field is intentionally NOT added there; only its SSE example string is updated.The value maps directly from
CompactionResult.compacted(set by the LCORE-1572 integration) via a newcontext_statusproperty onCompactionResult. The non-streaming endpoint reads it when buildingQueryResponse; the streaming compaction-aware path captures it from the yieldedCompactionResultand threads it throughgenerate_agent_response(new parameter, default"full") intoEndStreamPayload.create. The sharedContextStatusLiteral type alias lives inmodels/common/turn_summary.py./v1/responsesintentionally does not get the field (stays OpenAI-shaped, compacts silently per R12); the A2A executor is out of scope.The compaction design doc (
docs/design/conversation-compaction/conversation-compaction.md) is updated to record the two-place split, anddocs/devel_doc/openapi.jsonis regenerated (ContextStatusappears as a named enum schema referenced byQueryResponse.context_status; the streaming endpoint's SSE example showscontext_statusin theendevent).Type of change
Tools used to create PR
Identify any AI code assistants used in this PR (for transparency and review context)
Related Tickets & Documents
Checklist before requesting a review
Testing
Start the full local stack (Llama Stack + Lightspeed Stack, compaction disabled or defaults) and send a non-streaming query:
Expected: response JSON includes
"context_status": "full".Actual (verified locally against llama-stack 0.6.0):
Connect to the streaming endpoint and inspect the SSE
endevent:Expected: the
endevent'sdataincludescontext_status.Actual (verified locally):
The
"summarized"value could not be verified live: compacted-mode requests (explicit-input rewrite) currently fail with HTTP 500 on both/v1/queryand/v1/streaming_querybefore the response is built — a pre-existing issue in the agent pipeline (retrieve_agent_responsepassesresponses_params.inputthroughcast(str, ...)intoagent.run(), but in compacted modeinputis an item list). Filed as LCORE-3582. Thecompacted → "summarized"mapping is covered by unit tests at every layer (model,CompactionResultproperty, end-event payload, and both endpoint pipelines).Run the unit tests specific to this change:
Result: 10 passed.
Run the full suites:
Regenerate and inspect the OpenAPI schema:
Expected/Actual:
context_statuspresent onQueryResponsewith$refto theContextStatusenum (["full", "summarized"]); the/v1/streaming_querySSE example shows"context_status": "full"in theendevent.