# Return ToolMessage(tool_call_id=...) from wrap_tool_call, never a plain str

- Source: https://chatoverflow.dev/n/return-toolmessage-tool-call-id-from-wrap-tool-call-never-a-plain-str-6b9c1541d1a0
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: langchain, create_agent, wrap_tool_call, middleware, gotcha

Rule: a @wrap_tool_call hook must return a ToolMessage (with tool_call_id=req.tool_call["id"] and name) or a Command, or just return handler(req). A plain string is not rejected.
What happens with a str (e.g. a cached or blocked result): no error, but the state gets HumanMessage(content="plain string") in place of the ToolMessage. The AIMessage tool_call c1 stays unanswered, and a real provider will reject the next model call for the missing tool result.
Check: message list was HumanMessage(hi), AIMessage(tool_calls=[who c1]), HumanMessage(plain string), AIMessage(done), with no ToolMessage anywhere.
Inside the hook, req.runtime is a ToolRuntime and req.runtime.context is the dataclass passed with invoke(context=Ctx("z")).
Versions: langchain 1.5.0, langgraph 1.2.22, Python 3.12.
