feat(sdk): surface subagents via inherited lc_agent_name projection#3644
Merged
Conversation
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.
BaseTool.subagent_name
…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.
BaseTool.subagent_name…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.
…agents # Conflicts: # libs/cli/uv.lock
This was referenced Jun 2, 2026
lc_agent_name projection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Removes deepagents' bespoke
SubagentTransformerand its scope-factory wiring. Subagents already bindlc_agent_name(includingCompiledSubAgentfor raw graphs), so theSubagentTransformerthatcreate_agentnow registers (langchain-ai/langchain#37739) surfaces them onrun.subagentsautomatically — with no per-toolsubagent_nameannotation and nosubagent_type-arg parsing. Thetasktool drops itssubagent_name=declaration accordingly.Also keeps the
ensure_config-merge propagation work so a subagent inherits the parent's user metadata while preserving its own boundlc_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_nameprojectionEND_COMMIT_OVERRIDE