Skip to content

feat: add external session support and Agent tool recognition#115

Open
drewf wants to merge 1 commit intopablodelucca:mainfrom
drewf:feature/external-session-support-v2
Open

feat: add external session support and Agent tool recognition#115
drewf wants to merge 1 commit intopablodelucca:mainfrom
drewf:feature/external-session-support-v2

Conversation

@drewf
Copy link

@drewf drewf commented Mar 12, 2026

Summary

  • External session detection: Automatically detects and tracks Claude Code sessions running in the VS Code extension panel (WebSocket transport, no terminal). These produce JSONL transcripts like terminal sessions but have no associated Terminal object.
  • Agent tool recognition: Recognizes the renamed Agent tool (alongside Task) for sub-agent detection and permission exemption.
  • Stale cleanup: Periodically removes external agents whose JSONL files haven't been modified in 5 minutes.

Known limitations

  • External sessions rely on JSONL file mtime for stale detection — no close event is available for extension panel sessions, so agents linger up to 5 minutes after the session ends.

Relation to previous PRs

This supersedes #76 (Agent tool recognition) and #77 (external session support), combining both into a single PR rebased on current main (post-#82 formatting changes).

Test plan

  • Launch Claude Code from the VS Code extension panel — agent should appear
  • Launch multiple extension panel sessions — each gets its own agent
  • Close an extension panel session — agent disappears within ~5 minutes
  • /clear in a terminal session reassigns correctly (doesn't affect external agents)
  • Sub-agents via the Agent tool are recognized correctly
  • Restart VS Code — external agents with recent JSONL files restore

Detect and track Claude Code sessions running in the VS Code extension
panel (WebSocket transport, no terminal). These produce JSONL transcripts
like terminal sessions but have no associated Terminal object.

Changes:
- Make terminalRef optional, add isExternal flag to AgentState
- Add external session scanning (5s interval) and stale cleanup (5min timeout)
- Persist/restore external agents across reloads
- Guard terminal-specific code paths (focus, close, /clear reassignment)
- Recognize renamed 'Agent' tool alongside 'Task' for sub-agents

Known limitation: external sessions rely on JSONL file mtime for stale
detection (no close event available), so agents linger up to 5 minutes
after the extension panel session ends.

Supersedes pablodelucca#76 and pablodelucca#77.
@fuad00
Copy link

fuad00 commented Mar 18, 2026

waiting to be added to prod so much!

@fernandolangaro
Copy link

This PR will be insane, waiting for it!

@florintimbuc florintimbuc added type: feature New feature or capability area: agent-connection Agent discovery, session linking, transcript communication area: host Host layer: agentManager, fileWatcher, transcriptParser labels Mar 19, 2026
@joshua-quek-sonarsource

waiting for this too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: agent-connection Agent discovery, session linking, transcript communication area: host Host layer: agentManager, fileWatcher, transcriptParser type: feature New feature or capability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants