Skip to content

Agent View: Manage Multiple Claude Code Sessions from One Screen

Core Concept LearningAugust 18, 202610 min read

Agent View is a real-time dashboard that dispatches Claude Code sessions, monitors their status, throttles execution with input queues, and tracks cost across all running agents. Instead of juggling 50 terminal tabs, you see one unified view: running agents, completed tasks, pending queue, and total token spend.

This guide covers the Agent View API, how to wire it into your CI/CD, approval workflows (human-in-the-loop), and the scaling boundary. At 100+ concurrent agents, you'll hit token rate limits; we'll show you how to detect and handle backpressure. The real gotcha: runaway agents. We'll trace how a single agent bug can drain your budget in minutes and the circuit breaker pattern that stops it.

Dispatch and Manage Many Sessions at Once

Agent View exposes an API to spawn, monitor, and kill agent sessions. You POST a job (agent name, input, worktree path) to the dispatcher; it queues the job, executes it, and streams updates to the dashboard. You can cancel a running agent, see its real-time output, and mark a job as approved/rejected before execution.

The dispatcher maintains a job queue. When you submit 100 jobs, they don't all run at once. Instead, they wait for a free slot (based on max_concurrent_agents setting). This prevents resource exhaustion and lets you manage throughput.

Quick reference

  • POST /dispatcher/jobs creates a job with agent config, input, and worktree.
  • Each job gets a unique session_id.
  • Agent runs in subprocess; output streamed to WebSocket.
  • GET /dispatcher/jobs lists all jobs (running, queued, completed).
  • DELETE /dispatcher/jobs/{session_id} kills a running agent.
Dispatch a Job
1import requests2 3DISPATCHER_URL = "http://localhost:8000"4 5job = {6    "agent_name": "code-reviewer",7    "input": "Review PR #42 in anthropics/claude-ui",8    "worktree": "/path/to/worktrees/review-pr-42",9    "max_retries": 2,10    "timeout_seconds": 60011}12 13response = requests.post(f"{DISPATCHER_URL}/dispatcher/jobs", json=job)14session_id = response.json()["session_id"]15print(f"Job {session_id} dispatched")
Monitor and List Jobs
1import asyncio2import websockets3import json4 5async def monitor_job(session_id):6    uri = f"ws://localhost:8000/dispatcher/jobs/{session_id}/stream"7    async with websockets.connect(uri) as ws:8        while True:9            msg = await ws.recv()10            event = json.loads(msg)11            if event["type"] == "output":12                print(event["data"])13            elif event["type"] == "done":14                print(f"Status: {event['status']}")15                print(f"Tokens: {event['tokens_used']}")16                break17 18asyncio.run(monitor_job(session_id))

Remember this

Agent View dispatcher queues jobs, throttles concurrent execution, and streams output. Each job has a unique session_id.

Real-Time Status Dashboard

The dashboard is a web UI (or API endpoint) that shows all active jobs, their status (running, queued, completed, failed), elapsed time, token usage, and output tail. You can click on a job to see full output or kill it mid-execution.

The backend maintains a job store (in-memory or database) that tracks state. Every state change (queued → running → done) broadcasts to WebSocket clients. This means the dashboard updates in real-time without polling.

Quick reference

  • Dashboard queries GET /dispatcher/jobs for current state.
  • WebSocket connects to /dispatcher/subscribe for real-time updates.
  • Each update includes: session_id, status, output, tokens_used, elapsed_seconds.
  • Click to expand: full logs, error traces, tool calls.
  • Kill button: DELETE /dispatcher/jobs/{session_id} sends SIGTERM.

Remember this

Dashboard aggregates all sessions in one view. Real-time updates via WebSocket. Click to expand, kill to stop.

Input Queues and Approval Workflows

For critical workflows, you might want human approval before an agent runs. Agent View supports approval gates. When you POST a job with requires_approval: true, it enters the queue but doesn't execute. An approver reviews the input (and optionally the agent's plan), then approves or rejects via the dashboard.

Once approved, the job moves to execution. Once rejected, it's marked as skipped. This pattern is essential for infrastructure changes, financial transactions, or any high-stakes automation.

Quick reference

  • Create job with requires_approval: true.
  • Job enters approval queue; dashboard shows pending approvals.
  • Approver reviews input and context (agent description, output if dry-run).
  • POST /dispatcher/jobs/{session_id}/approve or /deny.
  • Approved → execution queue; Denied → marked as skipped.
Submit Job Requiring Approval
1job = {2    "agent_name": "db-migration",3    "input": "Run migration: add_indexes_to_users_table",4    "worktree": "/path/to/db-repo",5    "requires_approval": True,6    "dry_run": True  # Optional: run in simulation mode first7}8 9response = requests.post(f"{DISPATCHER_URL}/dispatcher/jobs", json=job)10session_id = response.json()["session_id"]11print(f"Job {session_id} awaiting approval")
Approve Job
1# Approver sees job in queue2# Reviews dry run output, then:3 4response = requests.post(5    f"{DISPATCHER_URL}/dispatcher/jobs/{session_id}/approve",6    json={"notes": "Dry run looks good, proceeding"}7)8 9# Job executes; dashboard shows progress

Remember this

Approval gates enable human oversight. Pending jobs wait for approval; approved jobs execute; rejected are skipped.

Cost Tracking Across Sessions

Every API call costs tokens. With 50 agents running, your bill multiplies fast. Agent View logs token usage per session and aggregates it. At the end of each job, it records input_tokens and output_tokens. The dashboard shows total tokens (and cost estimate) across all sessions.

You can set a hard budget cap: if cumulative cost exceeds $X, stop accepting new jobs and alert the team. This prevents runaway spending if an agent gets stuck in a loop.

Quick reference

  • Each job logs: input_tokens, output_tokens, model, timestamp.
  • Dashboard aggregates: total_tokens, estimated_cost (tokens * $rate).
  • Set budget limit: max_cumulative_cost (e.g., $100 per hour).
  • If limit exceeded: queue new jobs but don't execute; alert on Slack.
  • Log token usage per agent type (code-reviewer vs. db-migration) for optimization.
Check Cost Across All Jobs
1response = requests.get(f"{DISPATCHER_URL}/dispatcher/stats")2stats = response.json()3 4print(f"Total tokens: {stats['total_tokens']}")5print(f"Estimated cost: ${stats['estimated_cost']:.2f}")6print(f"Cost per agent type:")7for agent, cost in stats['cost_by_agent'].items():8    print(f"  {agent}: ${cost:.2f}")
Set Budget Alert
1import os2 3BUDGET_CAP_USD = float(os.getenv("AGENT_BUDGET_LIMIT", "100"))4 5def check_budget():6    response = requests.get(f"{DISPATCHER_URL}/dispatcher/stats")7    cost = response.json()["estimated_cost"]8 9    if cost > BUDGET_CAP_USD:10        # Send alert, block new jobs11        os.system("curl -X POST https://slack.com/api/chat.postMessage "12                  f"-d 'text=Agent cost exceeded ${cost:.2f} > ${BUDGET_CAP_USD}'")13        # DELETE /dispatcher/accept_new_jobs to pause14        requests.delete(f"{DISPATCHER_URL}/dispatcher/accept_new_jobs")

Remember this

Log tokens per session. Track cumulative cost. Set a budget cap and alert if exceeded.

Scaling Patterns (100s of Sessions)

At 10 concurrent agents, Agent View runs on a single machine. At 100, you need horizontal scaling: multiple dispatcher instances, a shared job store (database), and a message broker (Redis/Kafka) for job distribution.

The pattern: agents submit jobs to a queue (e.g., Redis list). Dispatcher instances pop jobs, execute them, and post results back to a results queue. The dashboard subscribes to the results queue and updates in real-time. This decouples job submission from execution, letting you scale execution independently.

Quick reference

  • Dispatcher instances are stateless; share a Redis job queue.
  • Job store (database): persists jobs for replay and audit.
  • Message broker: distributes jobs and results.
  • Dashboard subscribes to results channel for real-time updates.
  • Circuit breaker: if Anthropic API is rate-limited, back off exponentially.

Remember this

Scaling pattern: stateless dispatchers, shared queue, persistent store, message broker, circuit breaker.

Monitoring and Observability

With many agents, bugs compound. An agent that retries indefinitely can drain your budget in hours. Observability is how you catch it. Log every state transition (queued → running → done), every API call, every error. Expose metrics: job throughput (jobs/min), avg latency (seconds), error rate (%), token efficiency (tokens/job).

Key metrics to watch: job queue depth (if growing, dispatcher is too slow), max concurrent jobs (if stuck at limit, increase capacity), error rate (if spiking, agents are hitting bad state).

Quick reference

  • Log job lifecycle: submitted, queued, approved, running, done, failed.
  • Metrics: throughput (jobs/min), latency (p50, p95, p99), error rate.
  • Alerts: queue depth > 100, error rate > 5%, cost/hour > budget.
  • Expose metrics on /metrics endpoint (Prometheus format).
  • Dashboard shows: current jobs, job history, error logs, cost breakdown.

Remember this

Log every state change. Monitor queue depth, latency, error rate, and cost. Alert on anomalies.

Integration with Team Workflows

Agent View is most powerful when integrated into your team's workflow. Slack bot that posts job results into a channel. GitHub Actions that dispatch jobs and report status. Jira tickets auto-updated with agent output.

Example: A GitHub Actions workflow for pull requests. On PR open: dispatch a code-review agent to review the PR. Results posted as a GitHub comment. Approver checks the comment; if satisfied, approves the agent job, which can then auto-merge or notify the team.

This closes the loop: developer pushes PR → agent reviews → team approves → merge. All automatic, all tracked.

Quick reference

  • Slack integration: POST message to #agent-results with job summary.
  • GitHub integration: create PR comment with agent output.
  • Jira integration: update ticket with agent-generated subtasks.
  • Webhook: trigger dispatch on GitHub PR, Jira ticket creation, Slack command.
  • Feedback loop: emoji reactions on results for approval/rejection.

Remember this

Integrate Agent View into Slack, GitHub, Jira. Automate dispatch and close the human-in-the-loop workflow.

Key takeaway

Agent View lets you scale Claude Code to teams. Dispatch jobs, track cost, approve workflows, and integrate into your stack. For orchestrating multiple agents in sequence (e.g., code review → tests → merge), read the dynamic workflows guide. For cost optimization at scale, see the Agent SDK guide on token tracking.

Share:
PK

Polo Khan

Lead Author & Systems Architect

Software engineer and distributed systems architect specializing in backend scalability, cloud-native infrastructure, databases, and AI engineering workflows. Author and maintainer of Core Concept Learning.

Human-Engineered & Fact-CheckedOriginal Visual DiagramsEditorial Standards →Send Feedback

Related Articles

AI coding agents change where engineering effort is spent: the hard problem moves from typing code to defining boundarie

Read

An agent can turn a small ticket into a working patch quickly. It can also turn an ambiguous ticket into a convincing pi

Read

Claude Code is an agentic coding tool that can inspect a repository, propose edits, run permitted commands, and work thr

Read

Keep learning

Follow a structured path or browse all courses to go deeper.