惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

F
Fortinet All Blogs
Microsoft Security Blog
Microsoft Security Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Vercel News
Vercel News
Application and Cybersecurity Blog
Application and Cybersecurity Blog
C
Check Point Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
W
WeLiveSecurity
The Hacker News
The Hacker News
L
LINUX DO - 热门话题
T
Tenable Blog
Hugging Face - Blog
Hugging Face - Blog
Google Online Security Blog
Google Online Security Blog
博客园 - Franky
P
Proofpoint News Feed
H
Hacker News: Front Page
P
Privacy & Cybersecurity Law Blog
月光博客
月光博客
P
Proofpoint News Feed
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
The GitHub Blog
The GitHub Blog
云风的 BLOG
云风的 BLOG
博客园_首页
www.infosecurity-magazine.com
www.infosecurity-magazine.com
C
CERT Recently Published Vulnerability Notes
Forbes - Security
Forbes - Security
I
InfoQ
Stack Overflow Blog
Stack Overflow Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Attack and Defense Labs
Attack and Defense Labs
N
News and Events Feed by Topic
博客园 - 叶小钗
T
Threat Research - Cisco Blogs
aimingoo的专栏
aimingoo的专栏
D
Darknet – Hacking Tools, Hacker News & Cyber Security
小众软件
小众软件
大猫的无限游戏
大猫的无限游戏
MongoDB | Blog
MongoDB | Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Hacker News - Newest:
Hacker News - Newest: "LLM"
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - 司徒正美
O
OpenAI News
G
Google Developers Blog
Martin Fowler
Martin Fowler
罗磊的独立博客
S
SegmentFault 最新的问题
T
Tor Project blog
量子位

LangChain Forum - Topics tagged python-help

Null-drift: A bare-metal O(1) Memory Store for continuous LangGraph agents Clarification needed: Assistant config vs context and graph initialization Proposal: a small local helper for readable run traces via PR Proxy Authentication Required 407 What is the right way to dynamically create and run a graph? Re-Implement claude code's dynamic workflow using langchian & deepagents How to define a correct state for multi-agent system Response Format Groq Model Pydantic I hope to get some recommendations for practical skills Interrupt does not work correctly in LangGraph The Qwen3.6b model in fireworks through initchatmodel reporting hugely inflated tokens For parallel execution in Node, should i use the functional API? Potential Enhancement: Django-Managed PostgresSaver Pre-interrupt() code re-runs on resume — anti-pattern, or is there a sanctioned way to detect resume? Interrupt parallel branch execution Best practices for self-hosting LangGraph Server OSS without LangGraph keys Dynamically Enabling/Disabling Graphs in a LangGraph Server at Runtime LangGraph thread copy can take 12+ minutes: recommended production pattern? Will DeltaChannel be the default for AgentState.messages, or expected to stay opt-in? Proposal: additional docs for implementing custom DB checkpointers or a guide on generic base checkpointer Prompt_cache_retention: '24h' supported in langchain agents and where to provide it, inside invoke or while creating client? Could RAG pipelines realistically cause deployment timeouts, is Render suitable for first-time RAG deployments? How do I use langchain_postgres' init_vectorstore_table correctly? Proposal: Graph-wide default error handler for StateGraph (fallback for nodes without error_handler) Support timedelta for CachePolicy.ttl, consistent with TimeoutPolicy Anyone confirms this issue that deepagent ui streaming is disturb by update in deepagent or bug issue Best Stack for Building AI Applications Seeking help regarding the connection between Websocket and tool calls Tool invocation error with empty error message when using `InjectedState` + `Command` return in async tool How to use @langchain/react Built llmsessioncontract on AgentMiddleware: runtime enforcement of tool-call protocols — feedback wanted Improving citation accuracy and reducing hallucinations in custom Parent-Child RAG pipeline (Gemma3:4B + FAISS+BM25 + Cross-encoder reranker) Built a live autonomous AI agent network using LangGraph-style economics — looking for feedback How to use tool calling using ChatLlamaCpp and Gemma 4 E4B with create_agent? The Docs says open router can be used with init_chat_model but throws an error Interested to contribute to langgraph postgre checkpointer for multiple adapter support SSL certificate error from httpx with LangGraph server [Feature Request] Wire allowed_msgpack_modules in langgraph.json Serving an agent with the LangGraph CLI dev command Proposal: implement delete_for_runs for SQLite checkpoint savers WikipediaLoader endup in JSONDecodeError Human-in-the-loop approval dashboard for LangGraph agents — open source, free to deploy Should interrupt() be split into two primitives — one for human input, one for s2s data fetching? Feature Request: Driver abstraction for checkpoint-postgres: to build support for asyncpg and other adapters .Interested to contribute to langgraph (python) Feature Request: @task metadata How should I provide an agent to a LangGraph server? Parallel astream() on the same compiled graph leaks messages between streams Where should I define the name and description for subagents? Add Qdrant-backed checkpoint saver and memory store (langgraph-checkpoint-qdrant) The output content has been corrupted Feature Request: Simple cryptographic provenance for who authorized what in LangGraph multi-agent graphs LangGraph + PostgreSQL: Chat history and summarization best practice Using SQLRecordManager multi-agent systems debugging agent-to-agent Proposal: Add save_local and load_local to USearch VectorStore (Feature Parity with FAISS) Tiny LangGraph -> Assay evidence sample from tasks v2 Help with local RAG pipeline – poor retrieval quality, wrong page numbers LOGIC.md — declarative reasoning contracts that compile to LangGraph StateGraph Distinguishing internal vs final streamed chunks in Supervisor multi-agent architecture Are people hitting race conditions in multi-agent LangChain setups? How do ContextEditingMiddleware and SummarizationMiddleware interact when used together?Combining ContextEditingMiddleware + SummarizationMiddleware — execution order and behavior when both trigger? How to register type in langgraph Are there any frontends for interacting with a LangGraph agent? Langchain.schema is not available while using in python code In-place model update on a compiled create_agent and per-subagent model update for deep agents - is this possible? Feature Request: Native Support for A2A Protocol (Remote Agents as Sub-Graphs) Feature Request: Image Input support for ChatMistralAI Multiple response formats when creating agents? Unable to parse docstring from OpenAI schema Hosting an agent server on Heroku No cost displayed in LangSmith when using LiteLLM + LangGraph How should I deploy a self-hosted multi-agent system? New integration: langchain-w2a — LangChain tools for W2A-enabled websites LiteLLM Router in LangChain: Missing Model Name and Cost in LangSmith Traces Bogus warning messages after upgrading dependencies which could have security impact if not addressed `anyio.CancelScope(shield=True)` not working inside langgraph node Handling Non-PDF File Attachments in LangChain HumanMessage How are teams handling evals when agent pipelines span multiple LangSmith projects? Feature request: Configurable PostgreSQL schema for langgraph-checkpoint-postgres (parity with LangGraphJS) Using the useStream frontend API with custom FastAPI backend Qwen 3.5 tool calling How to propagate cancellation across multi-level LangGraph agents When to use config['configurable'] vs. context in graph nodes? Tool.func typing Structured data fields (1000+): Dedicated LLM channel vs vectorized field names? PollerCompletionQueue._handle_events BlockingIOError spam in LangGraph Cloud logs Parallel Nodes: how to manage failures or exceptions With too many fields, how should deepagents handle this properly? [LangSmith Studio Issue] when resuming from an interrupt inside a subgraph. it doesn't properly resume, instead restarts Guarding tool calls against prompt injection / exfiltration Feature Discussion: Opt-In Recursive Long-Context Executor for LangGraph Persisting HITL payloads Multi-Agent Architecture Are dynamic tool lists allowed when using create_agent? Langgraph RemoteGraph How to make an image tool?
[DashScope] reasoning parameter on ChatOpenAI breaks subagent tool calling — use separate models as workaround
2026-03-24 · via LangChain Forum - Topics tagged python-help

Bug: reasoning parameter causes tool_call chain error in DeepAgents subagent

Environment

Package Version
deepagents 0.4.11
langchain 1.2.12
langchain-openai 1.1.11
langgraph 1.1.3
Python 3.12+
LLM Provider Alibaba DashScope (OpenAI-compatible)
Model qwen3.5-122b-a10b

Description

When using ChatOpenAI with the reasoning parameter and create_deep_agent with subagents, the main agent works correctly (delegates task to subagent), but the subagent crashes during its internal tool call chain.

The reasoning parameter triggers the Responses API code path (_construct_lc_result_from_responses_api), which formats messages differently. When the subagent inherits this model and performs multi-step tool calling, the tool_call → tool_response message pairing breaks, and the LLM API rejects the request.

Reproduction Code

from langchain_openai import ChatOpenAI
from deepagents import create_deep_agent

# Tool functions (simplified)
async def query_kyc(company_name: str) -> str:
    """查询企业基本工商信息"""
    return "企业名称:xxx有限公司\n法人:张三\n..."

async def query_field(company_name: str, query: str) -> str:
    """根据用户意图查询企业详细字段"""
    return "纳税信用等级:A"

model = ChatOpenAI(
    model="qwen3.5-122b-a10b",
    base_url="https://dashscope.aliyuncs.com/compatible-mode/v1",
    api_key="sk-xxx",
    timeout=60,
    reasoning={              # ← This causes the issue
        "effort": "medium",
        "summary": "auto"
    }
)

subagent = {
    "name": "Business_agent",
    "description": "Query company information.",
    "system_prompt": "You are a business info assistant. Use tools to query data.",
    "tools": [query_kyc, query_field],
}

agent = create_deep_agent(
    model=model,
    system_prompt="You are an enterprise info expert.",
    subagents=[subagent]
)

import asyncio
async def main():
    async for chunk in agent.astream({"messages": [
        {"role": "user", "content": "查询xxx有限公司的基本信息,纳税等级,开户行,画像和标签"}
    ]}):
        print(chunk)

asyncio.run(main())

Actual Behavior

The main agent successfully delegates to the subagent via the task tool. Then the subagent crashes when it tries to call its own tools:

ValueError: ResponseError(code='server_error', message='<400> InternalError.Algo.InvalidParameter:
An assistant message with "tool_calls" must be followed by tool messages responding to each "tool_call_id".
The following tool_call_ids did not have response messages: message[4].role')

Full Stack Trace

Traceback (most recent call last):
  File "core/main_agent.py", line 63, in <module>
    asyncio.run(t1.quick_start(messages))
  File "core/main_agent.py", line 45, in quick_start
    async for chunk in agent.astream({"messages": messages}):
  File "langgraph/pregel/main.py", line 3111, in astream
    async for _ in runner.atick(
  File "langgraph/pregel/_runner.py", line 304, in atick
    await arun_with_retry(
  File "langgraph/pregel/_retry.py", line 211, in arun_with_retry
    return await task.proc.ainvoke(task.input, config)

  # --- Main agent's tools node spawns the subagent ---
  File "langgraph/prebuilt/tool_node.py", line 846, in _afunc
    outputs = await asyncio.gather(*coros)
  File "langgraph/prebuilt/tool_node.py", line 1191, in _arun_one
    return await self._awrap_tool_call(tool_request, execute)
  File "deepagents/middleware/subagents.py", line 463, in atask
    result = await subagent.ainvoke(subagent_state)

  # --- Inside subagent: model node tries to call LLM ---
  File "langgraph/pregel/main.py", line 3462, in ainvoke
    async for chunk in self.astream(
  File "langgraph/pregel/main.py", line 3111, in astream
    async for _ in runner.atick(
  File "langchain/agents/factory.py", line 1352, in amodel_node
    result = await awrap_model_call_handler(request, _execute_model_async)

  # --- Through middleware chain ---
  File "langchain/agents/middleware/todo.py", line 253, in awrap_model_call
  File "deepagents/middleware/filesystem.py", line 1126, in awrap_model_call
  File "deepagents/middleware/summarization.py", line 1024, in awrap_model_call

  # --- LLM call crashes here ---
  File "langchain/agents/factory.py", line 1321, in _execute_model_async
    output = await model_.ainvoke(messages)
  File "langchain_openai/chat_models/base.py", line 1744, in _agenerate
    return _construct_lc_result_from_responses_api(
  File "langchain_openai/chat_models/base.py", line 4423, in _construct_lc_result_from_responses_api
    raise ValueError(response.error)
ValueError: ResponseError(code='server_error', message='<400> InternalError.Algo.InvalidParameter:
An assistant message with "tool_calls" must be followed by tool messages responding to each "tool_call_id".
The following tool_call_ids did not have response messages: message[4].role')
During task with name 'model' and id '0f42eef9-ac9e-b585-321b-e9a3f65283f8'
During task with name 'tools' and id 'cb8ef8e4-8e89-0d95-ac39-68555be375f7'

Expected Behavior

The reasoning parameter should work with subagents that perform multi-step tool calling, or the subagent should be able to override the model to avoid inheriting the Responses API code path.

Workaround

Use separate model instances — subagent config supports a model field to override the main agent’s model:

model_with_reasoning = ChatOpenAI(..., reasoning={"effort": "medium", "summary": "auto"})
model_basic = ChatOpenAI(...)  # no reasoning

agent = create_deep_agent(
    model=model_with_reasoning,  # main agent: reasoning ON
    subagents=[{
        "name": "Business_agent",
        "model": model_basic,    # subagent: reasoning OFF ← fixes the issue
        "tools": [query_kyc, query_field],
        ...
    }]
)

Analysis

Root Cause

The issue is primarily in DashScope’s Responses API compatibility layer, not in langchain-openai or DeepAgents.

How it happens

  1. The reasoning parameter causes langchain-openai to switch from the Chat Completions API path to the Responses API path (see _use_responses_api at base.py:1512: if self.reasoning is not None: return True).

  2. langchain-openai constructs the request using Responses API format — messages become a flat input array with typed blocks (reasoning, function_call, function_call_output, etc.) via _construct_responses_api_input at base.py:4225.

  3. DashScope’s OpenAI-compatible endpoint receives this Responses API format and internally converts it back to Chat Completions format for processing. Evidence: the error message uses Chat Completions terminology (“assistant message with tool_calls”) rather than Responses API terminology (“function_call” / “function_call_output”).

  4. During this internal conversion, when multiple tool-calling rounds are flattened into the input array (with interleaved reasoning, function_call, and function_call_output blocks), DashScope’s conversion logic loses the tool_call → tool_response pairing, causing the validation to fail at message[4].

  5. The main agent is unaffected because it only makes a single tool call (the task tool), so there’s no multi-round accumulation. The subagent crashes because it performs multi-step tool calling internally.

Summary

  • Qwen model: Not involved — the request never reaches the model.
  • DashScope compatibility layer: Primary issue — its Responses API → Chat Completions internal conversion breaks multi-round tool calling message pairing.
  • langchain-openai: No bug — the Responses API format it generates is likely valid for OpenAI’s native API, but DashScope’s compatibility layer cannot handle it correctly.
  • DeepAgents: No bug — it simply passes messages through; it is not responsible for API format conversion.