Skip to content

The agent engineering platform.

chore(langchain_v1): use args for HITL (#33442)

Sydney Runkle760fc3bc1262
diff --git a/libs/langchain_v1/langchain/agents/middleware/human_in_the_loop.py b/libs/langchain_v1/langchain/agents/middleware/human_in_the_loop.py
index 89c220071a..a29b23e7ec 100644
--- a/libs/langchain_v1/langchain/agents/middleware/human_in_the_loop.py
+++ b/libs/langchain_v1/langchain/agents/middleware/human_in_the_loop.py
@@ -11,23 +11,23 @@ from langchain.agents.middleware.types import AgentMiddleware, AgentState
class Action(TypedDict):
- """Represents an action with a name and arguments."""
+ """Represents an action with a name and args."""
name: str
"""The type or name of action being requested (e.g., "add_numbers")."""
- arguments: dict[str, Any]
- """Key-value pairs of arguments needed for the action (e.g., {"a": 1, "b": 2})."""
+ args: dict[str, Any]
+ """Key-value pairs of args needed for the action (e.g., {"a": 1, "b": 2})."""
class ActionRequest(TypedDict):
- """Represents an action request with a name, arguments, and description."""
+ """Represents an action request with a name, args, and description."""
name: str
"""The name of the action being requested."""
- arguments: dict[str, Any]
- """Key-value pairs of arguments needed for the action (e.g., {"a": 1, "b": 2})."""
+ args: dict[str, Any]
+ """Key-value pairs of args needed for the action (e.g., {"a": 1, "b": 2})."""
description: NotRequired[str]
"""The description of the action to be reviewed."""
@@ -45,8 +45,8 @@ class ReviewConfig(TypedDict):
allowed_decisions: list[DecisionType]
"""The decisions that are allowed for this request."""
- arguments_schema: NotRequired[dict[str, Any]]
- """JSON schema for the arguments associated with the action, if edits are allowed."""
+ args_schema: NotRequired[dict[str, Any]]
+ """JSON schema for the args associated with the action, if edits are allowed."""
class HITLRequest(TypedDict):
@@ -150,8 +150,8 @@ class InterruptOnConfig(TypedDict):
)
```
"""
- arguments_schema: NotRequired[dict[str, Any]]
- """JSON schema for the arguments associated with the action, if edits are allowed."""
+ args_schema: NotRequired[dict[str, Any]]
+ """JSON schema for the args associated with the action, if edits are allowed."""
class HumanInTheLoopMiddleware(AgentMiddleware):
@@ -214,12 +214,12 @@ class HumanInTheLoopMiddleware(AgentMiddleware):
# Create ActionRequest with description
action_request = ActionRequest(
name=tool_name,
- arguments=tool_args,
+ args=tool_args,
description=description,
)
# Create ReviewConfig
- # eventually can get tool information and populate arguments_schema from there
+ # eventually can get tool information and populate args_schema from there
review_config = ReviewConfig(
action_name=tool_name,
allowed_decisions=config["allowed_decisions"],
@@ -244,7 +244,7 @@ class HumanInTheLoopMiddleware(AgentMiddleware):
ToolCall(
type="tool_call",
name=edited_action["name"],
- args=edited_action["arguments"],
+ args=edited_action["args"],
id=tool_call["id"],
),
None,
diff --git a/libs/langchain_v1/tests/unit_tests/agents/test_middleware_agent.py b/libs/langchain_v1/tests/unit_tests/agents/test_middleware_agent.py
index 888049923a..1ff6f014be 100644
--- a/libs/langchain_v1/tests/unit_tests/agents/test_middleware_agent.py
+++ b/libs/langchain_v1/tests/unit_tests/agents/test_middleware_agent.py
@@ -555,7 +555,7 @@ def test_human_in_the_loop_middleware_single_tool_edit() -> None:
"type": "edit",
"edited_action": Action(
name="test_tool",
- arguments={"input": "edited"},
+ args={"input": "edited"},
),
}
]
@@ -676,14 +676,14 @@ def test_human_in_the_loop_middleware_multiple_tools_edit_responses() -> None:
"type": "edit",
"edited_action": Action(
name="get_forecast",
- arguments={"location": "New York"},
+ args={"location": "New York"},
),
},
{
"type": "edit",
"edited_action": Action(
name="get_temperature",
- arguments={"location": "New York"},
+ args={"location": "New York"},
),
},
]
@@ -724,7 +724,7 @@ def test_human_in_the_loop_middleware_edit_with_modified_args() -> None:
"type": "edit",
"edited_action": Action(
name="test_tool",
- arguments={"input": "modified"},
+ args={"input": "modified"},
),
}
]
@@ -789,7 +789,7 @@ def test_human_in_the_loop_middleware_disallowed_action() -> None:
"type": "edit",
"edited_action": Action(
name="test_tool",
- arguments={"input": "modified"},
+ args={"input": "modified"},
),
}
]
@@ -801,7 +801,7 @@ def test_human_in_the_loop_middleware_disallowed_action() -> None:
):
with pytest.raises(
ValueError,
- match=r"Unexpected human decision: {'type': 'edit', 'edited_action': {'name': 'test_tool', 'arguments': {'input': 'modified'}}}. Decision type 'edit' is not allowed for tool 'test_tool'. Expected one of \['approve', 'reject'\] based on the tool's configuration.",
+ match=r"Unexpected human decision: {'type': 'edit', 'edited_action': {'name': 'test_tool', 'args': {'input': 'modified'}}}. Decision type 'edit' is not allowed for tool 'test_tool'. Expected one of \['approve', 'reject'\] based on the tool's configuration.",
):
middleware.after_model(state, None)
@@ -871,7 +871,7 @@ def test_human_in_the_loop_middleware_interrupt_request_structure() -> None:
assert len(captured_request["action_requests"]) == 1
action_request = captured_request["action_requests"][0]
assert action_request["name"] == "test_tool"
- assert action_request["arguments"] == {"input": "test", "location": "SF"}
+ assert action_request["args"] == {"input": "test", "location": "SF"}
assert "Custom prefix" in action_request["description"]
assert "Tool: test_tool" in action_request["description"]
assert "Args: {'input': 'test', 'location': 'SF'}" in action_request["description"]
@@ -912,7 +912,7 @@ def test_human_in_the_loop_middleware_boolean_configs() -> None:
"type": "edit",
"edited_action": Action(
name="test_tool",
- arguments={"input": "edited"},
+ args={"input": "edited"},
),
}
]