Repository navigation
feat(integrations): add a Deep Agents adapter - #2684
Conversation
create_deep_agent compiles every declarative subagent as a separate graph, so a middleware passed to it wraps only the main agent's model calls. The new powercontext-deepagents package installs PowerContextMiddleware on the main agent and a recall-only copy on each declarative subagent, and keeps auto_capture on the main agent so a delegated turn is stored once. PowerContextScope reaches subagents through the parent runtime context, so recall uses the same scope everywhere. Compiled and remote subagents own their graph; the adapter returns them unchanged and documents that their middleware must be added inside the graph. Tests cover middleware injection, subagent recall, single-capture ownership, an in-process Server recall for both the main agent and a delegated subagent, and the capability manifest entry.
…r Deep Agents Add regression coverage for the acceptance paths the adapter contract depends on: astream recall with a single capture, interrupt/resume capture ownership, repeated model calls without context accumulation, and Scope isolation between runs. Add a runnable example that connects to a real Server and an OpenAI-compatible endpoint, and record the real-model validation results (Deep Agents 0.7.39, LangChain 1.5.0, PowerContext Server 0.1.dev1, vLLM 0.29 serving Qwen2.5-0.5B) in both documentation locales.
…tion results for Deep Agents Streaming and interrupt/resume now have real-model evidence (astream: 17 chunks, one Source; interrupt_on: paused, resumed, one Source). Automatic Source-to-Memory extraction was attempted against local 0.5B/0.6B models and produced no Memory: the 0.5B model returned a structured result the Server rejected and the 0.6B model returned an empty candidate list, so extraction and semantic ranking remain unvalidated without a larger generation model and an embedding model.
…for Deep Agents Validation used vLLM-served Qwen3-4B for generation and bge-small-en-v1.5 for embeddings: a captured turn flushed into Memory and a paraphrased query returned a non-empty prepared context that the agent recalled in a new session. Record that 0.5B/0.6B models are too small for the extraction schema.
…mple for Deep Agents full_flow.py captures one turn, flushes it into Memory, waits for the extracted entry, and asks a paraphrased question in a new session; the guide and package README explain when the Server also needs an embedding model.
hidb4ai
left a comment
There was a problem hiding this comment.
The adapter leaves the default delegated agent without recall, does not enforce its parent-only capture contract for existing subagent middleware, and the published setup instructions import a nonexistent module. Please address the three inline findings before merging.
…e capture Three review findings: - Deep Agents creates a general-purpose subagent when no spec uses that name, and the adapter returned None, so default delegation ran without recall. Always supply that spec (built-in description and prompt; parent model, tools and interrupt_on stay inherited) with recall-only middleware; a caller-supplied or compiled spec with that name is kept instead of duplicated. - A declarative subagent that arrived with PowerContextMiddleware(auto_capture=True) was left untouched, so the delegated turn was captured too. Replace it with an equivalent recall-only copy that keeps trace_content, without mutating the caller's middleware or spec. - The guides installed only the LangChain adapter and imported a nonexistent powercontext_langchain.deepagents module. Install integrations/deepagents and import powercontext_deepagents in both locales. Cover the built-in subagent's recall through a real compiled graph (delegation to general-purpose), plus the normalization and duplicate-suppression cases.
|
All three findings are addressed in bd245a2 (18 deterministic tests now).
Verification: |
hidb4ai
left a comment
There was a problem hiding this comment.
Rechecked bd245a2: the three original reproductions are fixed. The new default-subagent insertion introduces one configuration regression: it re-enables delegation when the active harness profile explicitly disables the default subagent. See the inline finding.
The adapter always supplied an explicit general-purpose spec, and Deep Agents only honours GeneralPurposeSubagentProfile(enabled=False) when it auto-adds the default, so opting into PowerContext re-enabled delegation the application had disabled. Resolve the active harness profile before adding the spec: when it disables the default subagent, forward no extra spec so Deep Agents keeps the profile's behavior. Resolution is best effort and never blocks agent creation. Cover both the forwarded spec and a compiled graph whose model must not be offered the task tool under the disabled profile; both fail on the previous head.
|
Profile handling is fixed in aae2e71. Reproduction check with
|
… profile model=None is deprecated but supported in the pinned 0.7 range, and Deep Agents resolves it to its own default ChatAnthropic before applying the harness profile. The adapter returned early for None, so a profile that disables the default subagent was ignored and the explicit spec re-enabled delegation. Resolve the same effective model with Deep Agents' own default builder before the profile lookup; a failed default construction keeps the previous behavior because agent creation cannot proceed without that model anyway. Cover the default-model path with a registered disabled profile; it fails on the previous head.
|
Fixed in 1969426. Verified against your exact reproduction with real
|
hidb4ai
left a comment
There was a problem hiding this comment.
Rechecked 1969426: all previously reported correctness findings are fixed, including the default-model disabled-profile reproduction. No new blocking defect found in the updated paths. This review does not approve the added public Python interfaces; CI and real-provider acceptance remain separate gates.
The reported correctness defects were verified fixed at 1969426. Superseded by review 6006259133; this dismissal is not approval of the added public Python interfaces.
Which issue or RFC does this PR close?
Closes #2680. The JavaScript and Managed Deep Agents assessment stays out of this PR, as the issue requests.
Rationale for this change
create_deep_agentcompiles every declarative subagent as a separate graph, so a middleware passed tocreate_deep_agentwraps only the main agent's model calls: subagents would silently run without recall. Deep Agentsdoes forward the parent runtime context to the
tasktool, soPowerContextScopereaches subagents unchanged — noscope plumbing is needed, only middleware.
A thin adapter is enough. It installs
PowerContextMiddlewareon the main agent and a recall-only copy on eachdeclarative subagent, which keeps capture on the main agent so a delegated turn is stored once.
What changes are included in this PR?
powercontext-deepagentspackage underintegrations/deepagents:create_powercontext_deep_agent:create_deep_agentplus PowerContext middleware and a defaultcontext_schema=PowerContextScope;powercontext_deep_agent_middleware: reuses an existingPowerContextMiddleware, otherwise appends one with therequested
auto_capture;powercontext_subagents: copies declarative specs and appends a recall-only middleware; compiled (runnable)and remote (
graph_id) subagents are returned unchanged.meta.json, the capability inventory, and the manifest probe.devdependency group,[tool.uv.sources], anduv.lockentries for the new package.quickstart.py,full_flow.py).Are there any user-facing changes?
Additive only. The new package is optional, existing LangChain and LangGraph integrations are unchanged, and no Server
API changes are required. Deep Agents users gain bounded recall on the main agent and on declarative subagents, plus
opt-in completed-turn capture with a single Source per delegated turn.
How was this change tested?
injection and de-duplication, subagent recall, capture ownership,
astream, interrupt/resume capture, repeatedmodel calls without context accumulation, and Scope isolation between runs.
deepagents0.7.39,langchain1.5.0,langchain-core1.8.1, andlangchain-openai1.8.0 against a standalone PowerContext Server 0.1.dev1 (HTTP + SQLite):astreamdelivered 17 chunks with one Source;
interrupt_onpaused before the tool and stored one Source after resume.--runner pooling): a captured turn was flushed into Memory and a paraphrasedquery returned a non-empty prepared context that the agent recalled. Qwen2.5-0.5B and Qwen3-0.6B returned an
unusable or empty extraction result, so the docs record that a 4B-class model is required for extraction.
pytest tests/deepagents_adapter tests/langchain_middleware tests/test_integration_manifest.py(86 passed, 1 skipped),
ruff check,ruff format --check,python scripts/generate_integration_manifest_docs.py --check.AI usage statement
Built with an AI coding assistant (DeepSeek Harness). Every change was reviewed and executed locally against real
vLLM and PowerContext servers; the observed results, including the small-model extraction failures, are recorded in
the integration guides.