Skip to content

feat(dojo): deepagents subagents demo - #2351

Open
mme wants to merge 5 commits into
mainfrom
mme/subagents-langgraph-dojo
Open

feat(dojo): deepagents subagents demo#2351
mme wants to merge 5 commits into
mainfrom
mme/subagents-langgraph-dojo

Conversation

@mme

@mme mme commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Adds the deepagents_subagents demo to the dojo: a deepagents supervisor delegates to a research subagent that raises a LangGraph interrupt() from inside the subagent, showing both halves of the AG-UI subagent surface (shipped in @ag-ui 0.0.59) at once:

  • Attribution — every message carrying a subagentRunId renders inside that subagent's collapsible group, tagged with its name and live lifecycle status (running / finished / error / unregistered).
  • In-subagent human-in-the-loop — the interrupt propagates out of the subagent, the dojo renders Approve/Reject, and the decision resumes the same subagent on the same thread.

The demo consumes the raw protocol surface: a page-mounted provider subscribes to the AgentSubscriber callbacks (onSubagentStartedEvent / onSubagentFinishedEvent / onSubagentErrorEvent) and keeps the per-invocation lifecycle in React context — no framework hook, so the page doubles as the reference implementation for consuming the subagent lifecycle. (CopilotKit's useSubagent hook PR, CopilotKit/CopilotKit#5873, was closed in favor of this.)

Registered on the langgraph-fastapi lane only: the platform lane goes through the TypeScript LangGraphAgent client, which does not emit SUBAGENT_* events.

Also carried, as their own commits

  • @copilotkit/* 1.61.2 → 1.70.1 — the first CopilotKit release depending on the published @ag-ui 0.0.59. Plain released versions; no pins, no overrides.
  • Re-recorded langgraph-python event-trace goldens — the 1.66+ runtime stopped injecting the forwarded-headers "App Context" message, so every journey ran one STATE_SNAPSHOT short of its golden. (Recording note: the backend must run without LangSmith env vars, or parent_ids anonymize differently than CI's untraced runs — details in the commit message.)
  • A 6-line examples uv.lock refresh — main's lock still records the in-repo ag-ui-langgraph at 0.0.43 with a directory source for ag-ui-protocol; the integration's pyproject moved to 0.0.44 with a registry floor.

Verification

  • Deepagents e2e: grouping and identity tag, the in-subagent interrupt, approve and reject branches finishing visibly differently but cleanly, attribution surviving the final MESSAGES_SNAPSHOT, and no group left spinning after the run.
  • Both LangGraph platform lanes' agenticChatPage event-trace suites pass; files.json regenerated and byte-verified; dojo typechecks against released @copilotkit/react-core 1.70.1; pnpm install --frozen-lockfile succeeds with block-exotic-subdeps left enabled.
  • All CI checks green.

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Python Preview Packages

Version 0.0.0.dev1788537285 published to TestPyPI.

Warning: These packages are built from contributor code that may not yet have been vetted for correctness or security. Install at your own risk and do not use in production.

Install with uv

Add the TestPyPI index to your pyproject.toml:

[[tool.uv.index]]
name = "testpypi"
url = "https://test.pypi.org/simple/"
explicit = true

Then install the packages you need:

# Core SDK
uv add 'ag-ui-protocol==0.0.0.dev1788537285' --index testpypi

# Integrations (each already depends on the matching ag-ui-protocol preview)
uv add 'ag-ui-langgraph==0.0.0.dev1788537285' --index testpypi
uv add 'ag-ui-crewai==0.0.0.dev1788537285' --index testpypi
# NOTE: ag-ui-agent-spec depends on pyagentspec (git-only, not on PyPI).
# You will need to install pyagentspec separately from its git repo.
uv add 'ag-ui-agent-spec==0.0.0.dev1788537285' --index testpypi
uv add 'ag_ui_adk==0.0.0.dev1788537285' --index testpypi
uv add 'ag_ui_strands==0.0.0.dev1788537285' --index testpypi

Install with pip

pip install \
  --index-url https://test.pypi.org/simple/ \
  --extra-index-url https://pypi.org/simple/ \
  ag-ui-protocol==0.0.0.dev1788537285

Use --extra-index-url https://pypi.org/simple/ so pip can resolve
transitive dependencies (pydantic, fastapi, etc.) from real PyPI.


Commit: b38e937

@pkg-pr-new

pkg-pr-new Bot commented Aug 7, 2026

Copy link
Copy Markdown

Open in StackBlitz

@ag-ui/a2a-middleware

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/a2a-middleware@2351

@ag-ui/a2ui-middleware

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/a2ui-middleware@2351

@ag-ui/event-throttle-middleware

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/event-throttle-middleware@2351

@ag-ui/mcp-apps-middleware

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/mcp-apps-middleware@2351

@ag-ui/mcp-middleware

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/mcp-middleware@2351

@ag-ui/a2a

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/a2a@2351

@ag-ui/adk

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/adk@2351

@ag-ui/ag2

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/ag2@2351

@ag-ui/agno

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/agno@2351

@ag-ui/aws-strands

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/aws-strands@2351

@ag-ui/claude-agent-sdk

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/claude-agent-sdk@2351

@ag-ui/claude-managed-agents

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/claude-managed-agents@2351

@ag-ui/crewai

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/crewai@2351

@ag-ui/langchain

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/langchain@2351

@ag-ui/langgraph

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/langgraph@2351

@ag-ui/llamaindex

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/llamaindex@2351

@ag-ui/mastra

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/mastra@2351

@ag-ui/pydantic-ai

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/pydantic-ai@2351

@ag-ui/vercel-ai-sdk

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/vercel-ai-sdk@2351

@ag-ui/watsonx

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/watsonx@2351

@ag-ui/a2ui-toolkit

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/a2ui-toolkit@2351

create-ag-ui-app

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/create-ag-ui-app@2351

@ag-ui/client

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/client@2351

@ag-ui/core

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/core@2351

@ag-ui/encoder

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/encoder@2351

@ag-ui/proto

pnpm add https://pkg.pr.new/ag-ui-protocol/ag-ui/@ag-ui/proto@2351

commit: ec41b3d

@mme
mme force-pushed the mme/subagents-langgraph-dojo branch 4 times, most recently from 968753a to 2fbee22 Compare August 10, 2026 11:28
@mme
mme force-pushed the mme/subagents-protocol branch from b1bba2b to cb8d9f7 Compare August 10, 2026 14:16
@mme
mme force-pushed the mme/subagents-langgraph-dojo branch from 7eca6c0 to eeaa2a2 Compare August 10, 2026 14:20
Base automatically changed from mme/subagents-protocol to main August 25, 2026 08:39
parkerroan pushed a commit to parkerroan/ag-ui that referenced this pull request Aug 26, 2026
…ension, and subagent_visibility

The LangGraph half of the subagent work (protocol merged in ag-ui-protocol#2350),
split out of ag-ui-protocol#2351 so it can release independently of the dojo demo and
its CopilotKit preview pins. Byte-identical to the reviewed content on
mme/subagents-langgraph-dojo.

What the integration does:

- Derived attribution: LangGraph does not announce subagents, so nested
  checkpoint namespaces plus lc_agent_name identify each delegation;
  one STARTED/FINISHED pair per subagent under concurrency, per-lane
  steps, nested parents via boundary chains, per-lane public-id minting
  on collisions, input seeding and reverse translation for HITL resume.
- subagent_visibility = "inline" (default) | "attributed" | "hidden".
  Inline is byte-identical to pre-subagent behavior — pinned by a
  dedicated contract suite and verified against the PUBLISHED
  @ag-ui/core 0.0.55/0.0.57/0.0.58 transport schemas (92/92 events of a
  real capture parse clean). Attributed emits the full subagent
  surface. Hidden is invisible delegation (a design-partner request):
  only the parent's task call, its result, and the parent's reply reach
  the wire, with identity-paired, provenance-based suppression.
  emit_subagent_events remains a one-cycle boolean alias.
- HITL inside a subagent: suspension is a typed outcome, interrupts are
  attributed per interrupt, suspended lanes resume as continuations of
  the same subagentRunId (checkpoint task identity), and no-resume
  replays re-derive attribution from checkpoint evidence matching the
  deepagents task-call shape.

Release note (PNI-274, documented in pyproject): [tool.uv.sources]
still points ag-ui-protocol at the in-repo SDK — dev/CI-only, never in
wheel metadata. On the first ag-ui-protocol release carrying the
subagent events: raise the floor to that version, delete the block,
relock, then release ag-ui-langgraph. Module-scope imports make the new
floor mandatory (pre-subagent SDKs fail at import; pip must refuse the
pairing).

Suite: 603 tests + 5 subtests, including the flag-off byte-identity
contract, the hidden contract (28 tests), parallel/nested streaming,
and HITL resume. Review history: six-round design-partner-context
review, five-round clean-room review, design + four-round
implementation review for suspension, seven-round review for
subagent_visibility — all converged on real compiled graphs.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@mme
mme force-pushed the mme/subagents-langgraph-dojo branch from 687abc0 to 9a9eaa2 Compare August 28, 2026 10:31
@mme
mme force-pushed the mme/subagents-langgraph-dojo branch from 7be4fc0 to a7d1d8b Compare August 28, 2026 16:06
mme added 5 commits September 4, 2026 17:53
…urface

1.61.2 -> 1.70.1 across the six @CopilotKit dependencies. 1.70.1 is the first
CopilotKit release that depends on the published @Ag-ui 0.0.59 — the first
AG-UI release carrying the subagent surface (SUBAGENT_STARTED/FINISHED/ERROR,
the AgentSubscriber dispatch, and subagentRunId message attribution) — which
the deepagents_subagents demo (added later in this branch) consumes directly
via agent.subscribe.

Plain released versions: no pkg.pr.new pins, no overrides, and
block-exotic-subdeps stays enabled. Note: the runtime side of this bump stops
injecting the forwarded-headers 'App Context' message into the thread, which
moves the langgraph-python event-trace goldens — re-recorded in the next
commit.
Pairs with the CopilotKit 1.70.1 bump: the goldens were recorded against a
runtime that injected an 'App Context' message carrying
copilotkit_forwarded_headers as the thread's first message; the 1.66+ runtime
no longer injects it, so every journey ran one STATE_SNAPSHOT short of its
golden. Environment drift, not a regression: the TypeScript lane re-recorded
with no semantic changes, and its goldens never contained the injected
message.

Recording gotcha worth knowing: the backend must run WITHOUT LangSmith env
(LANGCHAIN_TRACING_V2 / LANGCHAIN_API_KEY / LANGSMITH_API_KEY). With tracing
on, the LangChain run tree gets a root id distinct from the platform run_id,
so raw-event parent_ids anonymize to a different id slot than CI's untraced
runs produce — the golden then fails only in CI, at
events[N].rawEvent.data.parent_ids[0].

Re-recorded via 'pnpm event-trace:update --spec agenticChatPage' against live
langgraph-cli backends with a clean env; both lanes pass in normal mode.
main's examples/uv.lock still records the in-repo ag-ui-langgraph path
dependency at 0.0.43 with ag-ui-protocol as a directory source; the
integration's pyproject has since moved to 0.0.44 with a registry floor
(ag-ui-protocol>=0.1.21, dev-only [tool.uv.sources] kept out of published
metadata per the PNI-274 plan). Relock so 'uv sync' in the examples — which
the deepagents_subagents demo lane runs against — resolves cleanly without
rewriting the lockfile.
A deepagents supervisor delegates to a research subagent that raises a
LangGraph interrupt() from INSIDE the subagent, so the demo shows both halves
of the subagent surface at once: attribution (each subagent's work rendered in
its own collapsible group, tagged with its identity and lifecycle status) and
an in-subagent human-in-the-loop pause that resumes on the same thread.

The demo consumes the protocol surface directly: a page-mounted provider
subscribes to the agent's onSubagentStartedEvent / onSubagentFinishedEvent /
onSubagentErrorEvent callbacks and keeps the per-invocation lifecycle in a
React context (started => running with the friendly name, finished => finished
— suspended included, error => error, unknown id => unregistered). The
provider subscribes from page mount because SUBAGENT_STARTED precedes the
subagent's first attributed message — the group component mounts too late to
hear it. No CopilotKit hook is involved, so the page doubles as the reference
for consuming the subagent lifecycle from the raw AG-UI surface (the
useSubagent hook PR, CopilotKit#5873, was closed in favor of this).

Registered on the langgraph-fastapi lane only. The platform lane goes through
the TypeScript LangGraphAgent client, which does not emit SUBAGENT_* events.

files.json embeds the demo source for the dojo's view-source panel and is
generated, not hand-written.
Covers what is specific to subagents rather than re-testing chat: the
delegation grouping and its identity tag, the interrupt raised inside the
subagent, and the two branches of that approval producing visibly different,
still-clean finishes.

Two invariants only a browser can check: attribution survives the final
MESSAGES_SNAPSHOT (a snapshot dropping subagentRunId would collapse every
group into the parent), and no group is left spinning once the run finishes.

The demo's own tool-result turns opt out of aimock's generic tool-result
acknowledgment, which is prepended and would otherwise make the approve and
reject branches read identically — the same carve-out every other demo with
its own post-tool-result reply uses.
@mme
mme force-pushed the mme/subagents-langgraph-dojo branch from 7b7120d to ec41b3d Compare September 4, 2026 15:54
@mme
mme marked this pull request as ready for review September 4, 2026 15:54
@mme
mme requested a review from a team as a code owner September 4, 2026 15:54
@mme mme changed the title feat(subagents): LangGraph integration and the deepagents dojo demo feat(dojo): deepagents subagents demo Sep 4, 2026
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