Skip to content

Show Claude Code subagents and outside sessions as characters - #405

Open
Omar-Tnzxo wants to merge 1 commit into
AgentSystemLabs:mainfrom
Omar-Tnzxo:feat/subagents-and-visitors
Open

Omar-Tnzxo wants to merge 1 commit into
AgentSystemLabs:mainfrom
Omar-Tnzxo:feat/subagents-and-visitors

Conversation

@Omar-Tnzxo

Copy link
Copy Markdown

What

Two ways to see more of what Claude Code is doing, in the office itself:

  • Subagents at the desk. Claude Code workers are now hooked for SubagentStart and SubagentStop too. Each subagent a worker has running (the Agent tool, a workflow's agents) stands round its chair as a smaller worker without a headset, with a card saying what kind it is, what it was asked to do (its agent-<id>.meta.json description) and its latest tool call (hooks fired from inside a subagent carry its agent_id, so its own PreToolUse updates it). It goes at SubagentStop; one stopped mid-turn without a word goes after 15 minutes of silence, and a new session has none. Past six round one desk, a sign says how many more.
  • Visitors. Claude Code sessions the office didn't start (the Claude desktop app, a terminal, an IDE) show up as visitors in the lobby between the elevator and the lounge, on the floor whose checkout their folder is in or whose repository their folder's origin is, else on the first floor marked as the lobby. Each has a card with its name in the app (or its first prompt), its folder and branch and its latest tool call, a status light (working, done, waiting on you, when it hops), and its subagents and workflow agents round it. Aiming at one says where it runs. --no-visitors (or AGENT_OFFICE_VISITORS=0) turns them off.

How it plugs in

Following docs/code-layout.md: no new code in main.ts, server.ts, the store or protocol.ts beyond one line in each list.

  • src/server/subagents.ts, plus two hook events and one call in providers/claude.ts; WorkerInfo.subagents (not saved in workers.json).
  • src/server/visitors/ (scan.ts, transcript.ts, index.ts): a building-wide service made in office/services.ts, a visitors message (protocol/visitors.ts) and a visitors field of FloorView (ws/handlers/visitors.ts).
  • Page: features/subagents/, features/visitors/, the visitors slice (last in SLICES), and world/character/subagent.ts for the figure both use.
  • --no-visitors in config.ts; README, docs/features.md, docs/how-it-works.md and docs/configuration.md updated.

Read-only, and what it reads

The visitor scan runs every 4 s only while someone is in the office. It lists and stats ~/.claude/projects ($CLAUDE_CONFIG_DIR/projects), restats transcripts older than 6 hours only once a minute, and reads only the first 64 KB and last 256 KB of transcripts written in the last 10 minutes (or with a subagent written to in the last 3), again only when one changed. Files are opened read-only and nothing is ever written, moved or locked there, and nothing is sent to those sessions; tests/visitors.test.ts checks a scan leaves every file's bytes and mtime as they were. Session ids that are, or ever were, the office's own workers' are skipped, and so are sessions inside a floor's .agent-office. Agent ids are checked against [A-Za-z0-9_-]{1,64} before they're used in a path. What browsers get is the title, folder (last two parts), branch, status, the latest tool call (one line, 80 characters) and the subagents' descriptions: anyone signed in to the office can already read all of that from a shell worker, but --no-visitors is there for an office whose people shouldn't see the host user's other sessions.

Verified

  • npm run typecheck, npm test (623 pass; tests/subagents.test.ts and tests/visitors.test.ts are new, and the pinned store and welcome lists in client-store and server-dispatch gained visitors), npm run build; tests/size.test.ts stays green.
  • Headless-browser screenshots on a test office: a Claude Code worker (Haiku) asked to run three Explore subagents had all three stand round its chair with their descriptions and tool calls, and desktop-app sessions, one running a workflow, showed as visitors on the floor of their repository with the workflow's agents round them.
  • A tarball packed the way release.yml packs it installs with install.sh (AGENT_OFFICE_TARBALL) and runs.

Checked against Claude Code 2.1.319, whose hook input has agent_id / agent_type on events from inside a subagent and agent_transcript_path on SubagentStop.

🤖 Generated with Claude Code

Subagents: Claude Code workers are now hooked for SubagentStart and
SubagentStop. Each running subagent is kept on the worker
(WorkerInfo.subagents, server/subagents.ts), with what it was asked to do
from its agent-<id>.meta.json and its latest tool call from its own
PreToolUse (hooks from inside a subagent carry its agent_id). The page
stands them round the worker's chair (features/subagents).

Visitors: Claude Code sessions the office didn't start (the desktop app,
a terminal, an IDE) are found under ~/.claude/projects (server/visitors/),
read-only: only stat'ed, listed and read in head and tail slices, never
written. Each shows in the lobby by the elevator of the floor whose
checkout or origin its folder is (else the first floor, marked as the
lobby), with its title, status, latest tool call and its subagents and
workflow agents round it (features/visitors). --no-visitors turns it off.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 9, 2026 17:33

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

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.

2 participants