_process_decision() — langchain Function Reference
Architecture documentation for the _process_decision() function in human_in_the_loop.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 786034cd_4c3c_2a16_2580_fdaf6714c856["_process_decision()"] b706912e_28f0_afbf_eb10_723aa3e74c52["HumanInTheLoopMiddleware"] 786034cd_4c3c_2a16_2580_fdaf6714c856 -->|defined in| b706912e_28f0_afbf_eb10_723aa3e74c52 c27d424a_40fd_dcec_b4d0_8dbf62b73ff2["after_model()"] c27d424a_40fd_dcec_b4d0_8dbf62b73ff2 -->|calls| 786034cd_4c3c_2a16_2580_fdaf6714c856 style 786034cd_4c3c_2a16_2580_fdaf6714c856 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain_v1/langchain/agents/middleware/human_in_the_loop.py lines 247–286
def _process_decision(
decision: Decision,
tool_call: ToolCall,
config: InterruptOnConfig,
) -> tuple[ToolCall | None, ToolMessage | None]:
"""Process a single decision and return the revised tool call and optional tool message."""
allowed_decisions = config["allowed_decisions"]
if decision["type"] == "approve" and "approve" in allowed_decisions:
return tool_call, None
if decision["type"] == "edit" and "edit" in allowed_decisions:
edited_action = decision["edited_action"]
return (
ToolCall(
type="tool_call",
name=edited_action["name"],
args=edited_action["args"],
id=tool_call["id"],
),
None,
)
if decision["type"] == "reject" and "reject" in allowed_decisions:
# Create a tool message with the human's text response
content = decision.get("message") or (
f"User rejected the tool call for `{tool_call['name']}` with id {tool_call['id']}"
)
tool_message = ToolMessage(
content=content,
name=tool_call["name"],
tool_call_id=tool_call["id"],
status="error",
)
return tool_call, tool_message
msg = (
f"Unexpected human decision: {decision}. "
f"Decision type '{decision.get('type')}' "
f"is not allowed for tool '{tool_call['name']}'. "
f"Expected one of {allowed_decisions} based on the tool's configuration."
)
raise ValueError(msg)
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does _process_decision() do?
_process_decision() is a function in the langchain codebase, defined in libs/langchain_v1/langchain/agents/middleware/human_in_the_loop.py.
Where is _process_decision() defined?
_process_decision() is defined in libs/langchain_v1/langchain/agents/middleware/human_in_the_loop.py at line 247.
What calls _process_decision()?
_process_decision() is called by 1 function(s): after_model.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free