Skip to content

feat(runtime): orchestrate targeted cross-agent compaction#3575

Merged
dgageot merged 1 commit into
mainfrom
feat/cross-agent-compaction-3439
Jul 10, 2026
Merged

feat(runtime): orchestrate targeted cross-agent compaction#3575
dgageot merged 1 commit into
mainfrom
feat/cross-agent-compaction-3439

Conversation

@Sayt-0

@Sayt-0 Sayt-0 commented Jul 10, 2026

Copy link
Copy Markdown
Member

Closes #3439

Summary

Adds a team-level live-session view to /context and explicit compaction targeting for individual sub-agent sessions.

The runtime tracks active RunStream sessions, including foreground delegation and run_background_agent work. Targeted requests are queued onto the selected session's own run loop and execute between model turns, preventing compaction from racing an in-flight turn.

Issue expectations

Expectation Implementation
Team-level /context view Lists the current root session and every live descendant session
Context budget per session Shows used tokens, context limit, and percentage, with an unknown-limit fallback
Target a named sub-agent Live rows show agent name and short session ID; Enter targets the exact session
Background-agent support Every active RunStream, including run_background_agent, is registered
Explicit user action Cross-agent targeting occurs only after selecting a row and pressing Enter
No idle auto-compaction No idle-triggered policy was added; existing threshold and overflow recovery behavior is unchanged
Safe event forwarding Sub-session compaction events do not cancel, idle, or drain queues for the root TUI session

Runtime flow

/context
  -> LiveSessions(current root)
  -> select live row
  -> CompactLiveSession(session ID)
  -> bounded request queue on target live-session entry
  -> target RunStream reaches a safe iteration boundary
  -> manual compaction events return through the App event stream

Accepted requests are drained before stream teardown. Requests on already-cancelled streams complete as skipped, avoiding a misleading started/failed sequence. Cached root-tree identity keeps long-running nested background sessions visible after an intermediate foreground parent finishes, while excluding stale sessions from a replaced root.

TUI behavior

  • Up/Down moves across live-session and attached-file rows.
  • Enter compacts a selected live session.
  • d, x, or Delete still drops a selected attachment.
  • The current/root row preserves the existing /compact path.
  • Targeted child compaction does not cancel the root stream or alter its working state.
  • The sidebar compaction indicator only follows the session currently displayed.

Design decisions and residual scope

  • Live-session listing and targeting are optional local-runtime capabilities, matching the existing optional context-breakdown pattern. Remote runtimes omit the live-session section and report targeted compaction as unsupported.
  • Harness-backed sessions have no regular model-loop iteration boundaries and no known context limit. An accepted request is therefore handled during teardown rather than interrupting harness execution.
  • Existing proactive threshold and overflow-recovery compaction remain active for sub-agent sessions. This change only adds explicit cross-agent orchestration.

Validation

Check Result
task build pass
task --force lint pass, 0 issues
Relevant package tests pass
Race tests for runtime, App, dialog, chat, sidebar, and TUI pass
Full task test pass with proxy variables unset, isolated Docker config, and Docker Model Runner marked unavailable
Adversarial review two cycles completed; blocking findings resolved

@Sayt-0
Sayt-0 requested a review from a team as a code owner July 10, 2026 11:12
@dgageot
dgageot merged commit 73c52c9 into main Jul 10, 2026
19 checks passed
@dgageot
dgageot deleted the feat/cross-agent-compaction-3439 branch July 10, 2026 11:21
Piyush0049 pushed a commit to Piyush0049/docker-agent that referenced this pull request Jul 15, 2026
…n-3439

feat(runtime): orchestrate targeted cross-agent compaction
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.

feat(runtime): cross-agent compaction orchestration (explicit, user-triggered)

2 participants