_build_cleared_tool_input_message() — langchain Function Reference
Architecture documentation for the _build_cleared_tool_input_message() function in context_editing.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD ee42af87_4c5e_4b39_d0f1_983638d93ef0["_build_cleared_tool_input_message()"] 342553be_63ff_6f10_00db_f8b52bed863a["ClearToolUsesEdit"] ee42af87_4c5e_4b39_d0f1_983638d93ef0 -->|defined in| 342553be_63ff_6f10_00db_f8b52bed863a 03942334_6db9_570a_7836_af54672f2984["apply()"] 03942334_6db9_570a_7836_af54672f2984 -->|calls| ee42af87_4c5e_4b39_d0f1_983638d93ef0 style ee42af87_4c5e_4b39_d0f1_983638d93ef0 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain_v1/langchain/agents/middleware/context_editing.py lines 158–184
def _build_cleared_tool_input_message(
message: AIMessage,
tool_call_id: str,
) -> AIMessage:
updated_tool_calls = []
cleared_any = False
for tool_call in message.tool_calls:
updated_call = dict(tool_call)
if updated_call.get("id") == tool_call_id:
updated_call["args"] = {}
cleared_any = True
updated_tool_calls.append(updated_call)
metadata = dict(getattr(message, "response_metadata", {}))
context_entry = dict(metadata.get("context_editing", {}))
if cleared_any:
cleared_ids = set(context_entry.get("cleared_tool_inputs", []))
cleared_ids.add(tool_call_id)
context_entry["cleared_tool_inputs"] = sorted(cleared_ids)
metadata["context_editing"] = context_entry
return message.model_copy(
update={
"tool_calls": updated_tool_calls,
"response_metadata": metadata,
}
)
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does _build_cleared_tool_input_message() do?
_build_cleared_tool_input_message() is a function in the langchain codebase, defined in libs/langchain_v1/langchain/agents/middleware/context_editing.py.
Where is _build_cleared_tool_input_message() defined?
_build_cleared_tool_input_message() is defined in libs/langchain_v1/langchain/agents/middleware/context_editing.py at line 158.
What calls _build_cleared_tool_input_message()?
_build_cleared_tool_input_message() is called by 1 function(s): apply.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free