Skip to content

feat(sdk): surface subagents via inherited lc_agent_name projection#3644

Merged
Mason Daugherty (mdrxy) merged 15 commits into
mainfrom
nh/subagent-name-deepagents
Jun 2, 2026
Merged

feat(sdk): surface subagents via inherited lc_agent_name projection#3644
Mason Daugherty (mdrxy) merged 15 commits into
mainfrom
nh/subagent-name-deepagents

Conversation

@nick-hollon-lc

@nick-hollon-lc Nick Hollon (nick-hollon-lc) commented May 28, 2026

Copy link
Copy Markdown
Contributor

Removes deepagents' bespoke SubagentTransformer and its scope-factory wiring. Subagents already bind lc_agent_name (including CompiledSubAgent for raw graphs), so the SubagentTransformer that create_agent now registers (langchain-ai/langchain#37739) surfaces them on run.subagents automatically — with no per-tool subagent_name annotation and no subagent_type-arg parsing. The task tool drops its subagent_name= declaration accordingly.

Also keeps the ensure_config-merge propagation work so a subagent inherits the parent's user metadata while preserving its own bound lc_agent_name (deepagents#3634).

Depends on langchain-ai/langchain#37739 and langchain-ai/langgraph#7928 (both unreleased) — pinned via temporary git revs in [tool.uv.sources]; replace with released floors before merge.

BEGIN_COMMIT_OVERRIDE
feat(sdk): surface subagents via inherited lc_agent_name projection
END_COMMIT_OVERRIDE

Declares subagent_name=lambda call: call['args']['subagent_type'] on
the task tool, replacing the bespoke deepagents SubagentTransformer
with the generic one langchain.agents now auto-registers. The
projection chain from declaration to run.subagents handle is provided
by langchain-ai/langgraph#7928 (ToolNode + Pregel scheduling hook)
and langchain-ai/langchain#37739 (SubagentTransformer reading
parent-scope metadata).

Removed:
- libs/deepagents/deepagents/_subagent_transformer.py (custom
  transformer + SubagentRunStream/AsyncSubagentRunStream handles,
  now provided by langchain)
- libs/deepagents/deepagents/_subagent_transformer.py tests
- _subagent_factory wiring + transformers=[...] kwarg from
  create_deep_agent
- SubagentTransformer / SubagentRunStream / AsyncSubagentRunStream
  exports from deepagents.__init__

Kept (for now):
- _build_subagent_config in middleware/subagents.py — gated on
  langgraph#7926 (ensure_config merge semantics) which has not
  shipped yet. Once that lands, callbacks/tags/configurable
  propagate automatically and only the ls_agent_type tag needs
  to be set explicitly.

Pins langchain (#37739) and langgraph (#7928) via [tool.uv.sources]
git URLs in libs/deepagents/pyproject.toml so CI can resolve before
those merge.

Drops the task_input assertion from streaming tests — the langchain
SubagentRunStream is tool-agnostic and does not carry per-tool
argument projections.
@github-actions github-actions Bot changed the title feat(deepagents): migrate task tool to BaseTool.subagent_name feat(sdk): migrate task tool to BaseTool.subagent_name May 28, 2026
@github-actions github-actions Bot added deepagents Related to the `deepagents` SDK / agent harness dependencies Pull requests that update a dependency file feature New feature/enhancement or request for one internal User is a member of the `langchain-ai` GitHub organization size: L 500-999 LOC labels May 28, 2026
@mdrxy Mason Daugherty (mdrxy) changed the title feat(sdk): migrate task tool to BaseTool.subagent_name feat(sdk): migrate task tool to BaseTool.subagent_name May 28, 2026
…ranch pins

The libs/deepagents pyproject pins langchain (PR #37739) and langgraph
(PR #7928) via [tool.uv.sources] git URLs. The example sub-project
depends on libs/deepagents as an editable path, so the branch SHAs
flow into its lock too. CI's uv lock --check needs the lock to match
the upstream SHAs.

When the upstream PRs merge and the pins become version constraints,
this lock should be regenerated again.
The latest langgraph push drops the frozen allowlist in
map_debug_tasks. Both the libs/deepagents and
examples/async-subagent-server locks pin langgraph via git URL, so
the SHA they record needs to match the upstream branch head for
CI lock-check to pass.
…36d2)

CI's lock-check walks every example; llm-wiki depends on deepagents
via editable path so the langgraph git pin propagates through and
the lock needs to match the upstream branch head.
Both examples depend on deepagents via editable path so the langchain
git pin propagates through. CI lock-check walks every example, so
all transitive consumers need their locks pinned to the current
upstream branch heads.
CI's lock-check walks every package via libs/Makefile (LIB_PACKAGE_DIRS +
EXAMPLE_PACKAGE_DIRS), each pinned to Python 3.12. Re-locking
individually with the project default Python (3.14) produced
inconsistent resolutions. Running 'make lock' from libs/ with the
CI-equivalent Python brings everything in sync.
Collapse _build_subagent_config: the parent's callbacks, tags, configurable
and metadata now reach subagents through langgraph's ensure_config ambient
merge (langgraph#7926) rather than explicit forwarding. Explicit forwarding
double-counted tags under the per-key merge; relying on the merge keeps the
subagent's bound config winning collisions (lc_agent_name, recursion_limit)
while parent user metadata (e.g. customer_id) now propagates into subagent
runs (deepagents#3634).

Add test_subagent_inherits_parent_user_metadata covering the propagation and
the preserved bound lc_agent_name.

Refresh uv.lock to the rebased langgraph #7928 (8c4afa17d), now stacked on
#7926's ensure_config merge.
Subagents already bind lc_agent_name (incl. CompiledSubAgent for raw graphs),
so the create_agent-provided SubagentTransformer (langchain#37739) surfaces them
on run.subagents automatically — no per-tool subagent_name annotation needed.
The bespoke transformer + factory removal on this branch stay. Bump dev pins to
the matching langchain#37739 / langgraph#7928 commits.
@nick-hollon-lc Nick Hollon (nick-hollon-lc) changed the title feat(sdk): migrate task tool to BaseTool.subagent_name feat(sdk): surface subagents via inherited lc_agent_name projection May 29, 2026
…agents

# Conflicts:
#	libs/deepagents/deepagents/graph.py
… floors

The subagent-streaming work this PR depends on shipped in langchain 1.3.3
(run.subagents projection, #37739) and langgraph 1.2.4 (lc_agent_name
lifecycle, #7928). Drop the temporary [tool.uv.sources] git-rev pins, bump
the langchain floor to >=1.3.3 (which pulls langgraph>=1.2.4 transitively),
and re-lock the workspace.
@mdrxy Mason Daugherty (mdrxy) merged commit e0a1ed2 into main Jun 2, 2026
64 of 67 checks passed
@mdrxy Mason Daugherty (mdrxy) deleted the nh/subagent-name-deepagents branch June 2, 2026 20:30
@mdrxy Mason Daugherty (mdrxy) changed the title feat(sdk): surface subagents via inherited lc_agent_name projection feat(sdk): surface subagents via inherited lc_agent_name projection Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deepagents Related to the `deepagents` SDK / agent harness dependencies Pull requests that update a dependency file feature New feature/enhancement or request for one internal User is a member of the `langchain-ai` GitHub organization size: L 500-999 LOC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants