Skip to content

feat(agentic): persist subagent sessions and stabilize flow chat session handling#812

Merged
wsp1911 merged 6 commits into
GCWing:mainfrom
wsp1911:main
May 20, 2026
Merged

feat(agentic): persist subagent sessions and stabilize flow chat session handling#812
wsp1911 merged 6 commits into
GCWing:mainfrom
wsp1911:main

Conversation

@wsp1911
Copy link
Copy Markdown
Collaborator

@wsp1911 wsp1911 commented May 20, 2026

Summary

This PR improves subagent session persistence and lineage tracking across core, desktop APIs, transport, and the shared web UI. It also fixes several flow chat consistency issues, especially around late stream/tool events, rollback cleanup, and a couple of UX edge cases in BTW and terminal interactions.

What Changed

  • Persist internal/background subagent sessions and surface their state in Flow Chat
  • Unify child session lineage around a structured relationship model
  • Preserve round affinity for late stream chunks and tool events
  • Cascade-delete hidden subagent sessions when rolling back turns
  • Scope Escape handling correctly so terminal shortcuts are respected
  • Hide the user message edit action in the BTW session panel

Details

Subagent session persistence and visibility

  • Persist internal subagent sessions using relationship metadata instead of treating them as hidden non-persisted sessions
  • Add restore flows for internal sessions across desktop API, transport, and service layers
  • Surface background subagent state in the Flow Chat UI
  • Add localized labels and UI support for subagent projection/status display

Child session lineage refactor

  • Introduce a structured session relationship contract across core, desktop API, and web UI
  • Stop persisting /btw child sessions as normal session data by using an ephemeral child session kind where appropriate
  • Persist review/deep review/subagent lineage through relationship metadata and manifest payloads
  • Remove legacy frontend lineage writes while keeping compatibility reads for older data
  • Clear legacy child lineage during session branching

Late event / round consistency

  • Add round_id to tool events across core, transport, and frontend handling
  • Ensure late text/thinking chunks and tool events attach to their original round instead of drifting to the latest round
  • Reject tool events that are missing round context rather than silently mis-associating them
  • Add regression coverage for late text, thinking, and tool event scenarios

Rollback cleanup

  • Ensure rolled-back turns also clean up related hidden subagent sessions to avoid stale session artifacts

UX fixes

  • Respect terminal shortcut scope for Escape handling
  • Hide the user message edit action inside the BTW session panel

Impact

This PR mainly improves:

  • session restore correctness
  • child/subagent session modeling
  • event-to-round consistency in Flow Chat
  • rollback hygiene
  • a few frontend interaction edge cases

Testing

  • Added/updated regression coverage for:
    • child session restore and lineage persistence
    • metadata compatibility
    • late text/thinking/tool event handling
    • BTW session flows
    • subagent projection behavior

Notes

This PR includes both backend and frontend changes, with the main theme being session relationship normalization and more reliable subagent/round behavior across the stack.

wsp1911 added 6 commits May 20, 2026 23:22
…und subagent state

- persist internal subagent sessions with relationship metadata instead of treating them as non-persisted hidden sessions
- add include_internal restore flows and dedicated subagent-session-linked events across desktop, transport, and service APIs
- simplify agent stream and event handling by removing per-event subagent parent payloads and linking child sessions through session metadata
- add flow chat background subagent projection UI, session metadata support, and localized labels for subagent status
- update store, websocket handling, and tests to cover internal session restore paths and subagent projection behavior
…tionship

- add structured session relationship contract across core, desktop API, and web UI
- stop persisting /btw child sessions by introducing EphemeralChild session kind
- persist review, deep review, and subagent lineage via relationship and deep review manifest payloads
- remove frontend legacy relationship writes from session metadata persistence
- clear legacy child lineage when branching sessions and keep fallback reads for old data
- add regression tests for child session restore, lineage persistence, and metadata compatibility
- reuse existing text and thinking items for late chunks on closed rounds
- add round_id to tool events across core, transport, and frontend handling
- attach late tool Started/EarlyDetected events to their original round
- reject tool events missing round context instead of falling back to the latest round
- add regression coverage for late text, thinking, and tool event scenarios
@wsp1911 wsp1911 marked this pull request as ready for review May 20, 2026 15:40
@wsp1911 wsp1911 merged commit fdaf3ea into GCWing:main May 20, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant