HITL Middleware per-call edited arguments are not saved

Hey there,

In the new per-call middleware, in edit mode the modified arguments are only “saved” in an unstructured fashion with the note inserted in front of the tool result. In the context of a chat application it makes it impossible to display tools arguments properly and simply. It means either having to parse the note or add the arguments in some dedicated field in metadata or additional_kwargs which is not wanted.

Am I missing something ?

Thanks in advance

Hi @JuR-0

As of langchain 1.4.6, that’s how per-call mode works - the edit is applied to the tool call request right before execution, the AIMessage keeps the model’s original tool call, and the only persisted record is the note prepended to the ToolMessage. Nothing structured is written anywhere.

Earlier versions rewrote the tool call on the AIMessage, and reasoning models kept re-issuing their original call because the history showed a call they never made ( Agent re-attempts original tool call after HumanInTheLoopMiddleware edit decision · Issue #33787 · langchain-ai/langchain · GitHub ). The note is there to tell the model what ran instead.

There’s an open feature request to record the human decision on the ToolMessage in machine-readable form, for both modes: `HumanInTheLoopMiddleware`: record the human decision on the resulting ToolMessage · Issue #41569 · langchain-ai/langchain · GitHub . Worth adding your use case there, since the shape (response_metadata vs additional_kwargs) is still being decided.

In the meantime, a small wrap_tool_call middleware listed after the HITL middleware receives the edited request and can stamp it onto the ToolMessage’s response_metadata, so you get the executed arguments without parsing the note: Custom middleware - Docs by LangChain

Best,
Chad