Skip to content

feat(dev): open the agent inspector from project dev - #2013

Open
tejaskash wants to merge 11 commits into
feat/dev-otel-collectorfrom
feat/agent-inspector
Open

feat(dev): open the agent inspector from project dev#2013
tejaskash wants to merge 11 commits into
feat/dev-otel-collectorfrom
feat/agent-inspector

Conversation

@tejaskash

@tejaskash tejaskash commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

What this does

agentcore project dev now opens the Agent Inspector — the local web UI from the current CLI — by default. The browser opens automatically on an interactive terminal (never in scripts or --json), the URL always prints, and --no-ui restores plain log streaming. From the UI you can see every runtime in the project, start any of them with a click, chat with a running agent, and browse its traces as they arrive. Edits to agentcore.json reload the agent list live. The web UI itself is the unmodified @aws/agent-inspector package — this PR provides everything behind it.

Scope: local dev loop only, deliberately

This PR is at full parity with the current CLI for everything reachable in the refactor today: supervise and lazily start all runtimes, chat over HTTP/SSE, local MCP + A2A + AGUI proxying, live traces, resources view, config-watch reload, the same security guards (loopback Host check, origin allowlist, X-Agentcore-Local on POSTs).

What it intentionally does not include: the deployed-target features of the current CLI's dev UI (invoke deployed agents, deployed memory records, CloudWatch traces, harness invocation). project deploy is still a stub on refactor, so those features would be dead code behind unreachable routes — an earlier draft carried them as unwired interfaces and a review rightly called that out (~1,200 lines removed). The SPA already degrades gracefully on their 404s; they return together with real wiring when deploy lands. One known cosmetic difference: agent ports scan per-protocol defaults rather than mainline's uiPort+1+index scheme.

How it fits together

  • DevSupervisor (core/dev/supervisor.ts) — agents start lazily when the browser asks, each in an abort scope chained to Ctrl-C for its whole lifetime; all runner output merges into one agent-attributed stream ([hello_world] ... in the terminal, an agent field in NDJSON). Hot reload stays inside the child (uvicorn --reload / tsx watch); setRuntimes applies config edits without touching running agents.
  • Inspector server (core/dev/inspector/) — the local route surface ported wire-compatibly from the current CLI's web-ui: status, start, protocol-aware /invocations, traces, /api/mcp, A2A agent card, resources, static SPA with SPA-routing fallback and per-process asset caching.
  • Storage/presentation split (from feat(dev): collect local OTEL traces in project dev #1980's review): TraceStore is raw per-trace persistence; frontend shaping (flattening, noise filtering) lives in core/dev/inspector/. io/httpServer streams AsyncIterable bodies for SSE, skips body buffering on GET/HEAD, and caps request sizes.
  • Assets — the SPA (4 text files, 616KB) is staged from node_modules into the ordinary asset pipeline at build time (gitignored), so the npm bundle and all six compiled binaries ship it with zero new distribution code. Bun bundles bare .html entrypoints through its HTML-imports pipeline, so staged files carry a neutral .asset suffix stripped on read. AGENT_INSPECTOR_PATH overrides for SPA development (uncached).

How it was tested

Beyond the unit/route suite (1,595 tests green): a full end-to-end session against a real project and a real Bedrock call — built the npm bundle, scaffolded a project with project create (real uv sync), ran project dev, and drove the Inspector with Playwright from the browser origin: SPA renders, agent starts via the UI (CORS + local-header guards exercised), an invocation streams back from Bedrock through the proxy, traces appear in the timeline with span counts, trace detail resolves by id, and foreign-origin POSTs are rejected 403. 10/10 checks, re-run after the trim. A separate headed session via the Playwright MCP server confirmed the same flow interactively (chat answered live, span waterfall rendered).

Stack

Stacks on #1980 (feat/dev-otel-collector); retarget as the stack merges. Together they complete the local dev-loop plan: #1980 collects traces, this PR shows them. Follow-up (blocked on deploy landing in the refactor): wire the deployed-target Inspector capabilities.

@github-actions github-actions Bot added the size/xl PR size: XL label Aug 17, 2026
@github-actions github-actions Bot added agentcore-harness-reviewing AgentCore Harness review in progress and removed agentcore-harness-reviewing AgentCore Harness review in progress labels Aug 17, 2026
@github-actions github-actions Bot added size/xl PR size: XL and removed size/xl PR size: XL labels Aug 17, 2026
@tejaskash
tejaskash force-pushed the feat/dev-otel-collector branch from 7e315b9 to aabb87f Compare August 18, 2026 18:16
…ream HTTP bodies

TraceStore becomes raw per-trace persistence; frontend shaping (meta, detail,
noise filtering) moves to core/dev/inspector with an InspectorTraceSource
query wrapper. io/httpServer responses can now stream AsyncIterable bodies
for SSE.
Agents start on demand (the Inspector's POST /api/start path), each in an
abort scope chained to the command signal for its whole lifetime, with every
runner's events merged into one attributed stream for the dev handler to
render. Start dedup and retry-after-failure fall out of a per-agent state
machine.
Stage @aws/agent-inspector's prebuilt dist-assets into the (gitignored)
asset tree at build time so the npm bundle mirrors it into dist/assets and
compiled binaries embed it — zero new distribution-aware code. At runtime
InspectorAssets resolves AGENT_INSPECTOR_PATH (SPA development), then the
staged assets, then node_modules (running from source before a build).
Bun.build bundles bare .html entrypoints through its HTML-imports pipeline
(colliding with the SPA's own index.js) instead of embedding them verbatim.
Staged files carry an .asset suffix that InspectorAssets strips on read.
createInspectorHandler composes a pure request handler for the Inspector
SPA over consumer-owned dependency interfaces (supervisor, traces, static
assets, project, optional AWS capabilities). Ports the reference web-ui
server's security model (loopback Host check, origin allowlist,
X-Agentcore-Local on POSTs, CORS preflight) and its wire contract:
status, start, protocol-aware /invocations proxying (HTTP/A2A/AGUI SSE
translation, deployed runtimes, harness invocations), local and deployed
MCP proxying, A2A agent cards, local and CloudWatch traces, memory
browsing/search, the project resource graph, and SPA static serving with
an index.html fallback. AWS-backed routes degrade to 404 error envelopes
when their capability is not wired.
project dev now supervises every runtime and serves the Inspector UI
(auto-opening the browser on interactive terminals only; --no-ui restores
plain single-runtime streaming, --ui-port pins the UI port). Events from
all agents render agent-attributed in human and NDJSON output.
…ency

Watch the project config so the Inspector's agent list follows edits without
a restart (running agents survive removal until they stop). Cache decoded SPA
assets outside SPA-dev mode, skip body buffering on GET/HEAD, and drain the
supervisor's event queue in batches.
project deploy is still a stub on the refactor branch, so nothing can ever
inject the aws capabilities: the deployed invocation/MCP, harness, memory,
CloudWatch trace, and deployed-state resource routes were unreachable dead
surface that always answered 404. Remove them and their dep interfaces,
wire types, and tests; unknown /api paths keep returning the same JSON 404
the SPA already handles. They return with real wiring when deploy lands.
Only StatusResponse and ResourcesResponse were referenced, each annotating a
literal that already expresses the exact SPA wire shape; the other 15
interfaces had no references at all. The literals stay the documented
contract.
@tejaskash
tejaskash force-pushed the feat/agent-inspector branch from 7cb567a to 937d318 Compare August 18, 2026 18:18
@github-actions github-actions Bot added size/xl PR size: XL and removed size/xl PR size: XL labels Aug 18, 2026
@tejaskash tejaskash changed the title feat(dev): Agent Inspector for project dev feat(dev): open the agent inspector from project dev Aug 18, 2026
@github-actions github-actions Bot added size/xl PR size: XL and removed size/xl PR size: XL labels Aug 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/xl PR size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant