perf(streaming): bound terminal session payloads - #6818
starship-s wants to merge 1 commit into
Conversation
d717724 to
7cb4a47
Compare
|
| Filename | Overview |
|---|---|
| api/streaming.py | Introduces the shared bounded, redacted terminal-session projection and uses it across native terminal lifecycle events. |
| api/gateway_chat.py | Aligns gateway completion and terminal-error events with the bounded terminal-session payload contract. |
| api/session_ops.py | Centralizes clipping of large tool-result rows for limited session payloads. |
| api/routes.py | Reuses the centralized limited-payload clipping helper for paginated session responses. |
| static/messages.js | Validates and merges terminal transcript windows while preserving expanded history and capped tool-call metadata. |
| static/sessions.js | Keeps authoritative sidebar message counts synchronized through optimistic and terminal transitions. |
| tests/test_terminal_session_tail_and_merge.py | Exercises payload bounds, coordinate validation, expanded-window preservation, keyed replacement, and repeated unkeyed metadata reconciliation. |
Sequence Diagram
sequenceDiagram
participant Runtime
participant SSE as Terminal SSE
participant Browser
Runtime->>Runtime: Persist complete session
Runtime->>Runtime: Select bounded message tail
Runtime->>Runtime: Project and cap tool metadata
Runtime-->>SSE: Session window + offset + total count
SSE-->>Browser: done / cancel / error
Browser->>Browser: Validate coordinates and metadata
Browser->>Browser: Merge authoritative tail with loaded prefix
Browser->>Browser: Preserve omitted keyed and repeated unkeyed calls
Browser->>Browser: Render settled transcript
Reviews (13): Last reviewed commit: "perf(streaming): bound terminal session ..." | Re-trigger Greptile
7cb4a47 to
6a1dd7d
Compare
|
Thanks @starship-s — this is a genuinely valuable fix (unbounded terminal Holding for one CORE fix: CORE — auto-compression settlement collapses an expanded transcript to the bounded tail (
|
6a1dd7d to
354a97b
Compare
|
Fixed and re-pushed at Added regression coverage for rotated |
354a97b to
7954613
Compare
|
Thanks @starship-s — the compression-rotation fix is spot on. I re-gated the new head One more edge — a separate cap that silently drops data, this time on tool calls rather than messages: SILENT — terminal settlement drops tool cards when a session has >300 tool calls (
|
7954613 to
0edf6be
Compare
|
@nesquena-hermes Re-pushed the final tool-metadata cap fix at |
0edf6be to
c40c001
Compare
|
@nesquena-hermes Re-pushed the repeated-unkeyed tool metadata fix at |
SummaryRe-gated at The server now emits a coordinate-complete tail contract in Code referenceThe current merge gate is now explicit and fail-closed: const sameCoordinateLineage=incomingSid===currentSid||incomingParentSid===currentSid;
if(!currentSession||!Array.isArray(currentMessages)||!currentSid||!sameCoordinateLineage){
return {...incoming,messages:incomingMessages};
}
...
if(incomingEnd!==messageCount) return null;The truncated tool-call case is also no longer shape-set deduplication. Diagnosis / recommendationThe implementation now preserves the pagination coordinate contract while removing the ordinary post-turn full-session payload. Failure cases still return Verification stepCI is green on the current head. I did not execute code from the PR worktree. For final manual verification, the highest-value cases are a long session ending normally, cancelling while viewing a paginated tail, and an auto-compression continuation with repeated legacy tool calls that lack IDs. Those correspond directly to the three coordinate branches reviewed above. |
e56acd5 to
648896b
Compare
|
Updated this branch onto current |
Assisted-by: Hermes Agent:gpt-5.6-sol Assisted-by: Codex:gpt-5.6-luna Assisted-by: Claude Code:claude-opus-5
648896b to
af69c4a
Compare
Thinking Path
Contract Routing
Task type: Runtime/streaming performance and settlement-correctness fix.
Touched areas: Native and gateway terminal SSE payloads, terminal session reconciliation, sidebar message counts, paginated tool-result bounding, and focused regression coverage.
Relevant public docs:
AGENTS.mdCONTRIBUTING.mddocs/CONTRACTS.mddocs/rfcs/stable-assistant-turn-anchors.mdScope boundaries: Preserve existing settlement semantics and transcript ownership. This PR does not change persisted session data, public APIs, visual layout, or the accepted terminal-state contract.
What Changed
Why It Matters
UI Evidence
Not applicable. This PR does not change visual layout or styling. The user-visible behavior is terminal settlement performance and transcript continuity, covered by executable payload and browser-state tests.
Verification
Targeted terminal and neighboring regression coverage:
./scripts/test.sh -q tests/test_terminal_session_tail_and_merge.py tests/test_issue856_background_completion_unread.py tests/test_auto_compression_terminal_failure.py tests/test_cancelled_turn_status.py tests/test_reasoning_chip_btw_fixes.py tests/test_live_to_final_anchor_visible_order.pyResult:
144 passedAll changed test files:
pytest -q -p no:randomly <changed test files>Result:
379 passedAdditional frontend regression coverage:
Result:
2,758 passedSyntax and hygiene:
node --check static/messages.jsnode --check static/sessions.jsgit diff --checkResult: all passed.
Synthetic payload checks:
Risks / Follow-ups
akay64documented important window-width, rotation, and ownership invariants. This PR uses a different implementation: producer-bounded terminal payloads with synchronous browser reconciliation.Model Used
gpt-5.6-solfor investigation, specification, orchestration, and verification.gpt-5.6-lunaat maximum reasoning effort for implementation and adversarial review.claude-opus-5through Claude Code at high effort for independent correctness review.