test_command_with_custom_state_field() — langchain Function Reference
Architecture documentation for the test_command_with_custom_state_field() function in test_wrap_model_call_state_update.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD e327cf86_4eab_962c_02fa_5a242f4ebbbb["test_command_with_custom_state_field()"] 32ccf275_216c_0c5f_4a10_07f3bc9d69a5["TestBasicCommand"] e327cf86_4eab_962c_02fa_5a242f4ebbbb -->|defined in| 32ccf275_216c_0c5f_4a10_07f3bc9d69a5 style e327cf86_4eab_962c_02fa_5a242f4ebbbb fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_wrap_model_call_state_update.py lines 115–142
def test_command_with_custom_state_field(self) -> None:
"""When command updates a custom field, model response messages are preserved."""
class CustomFieldMiddleware(AgentMiddleware):
def wrap_model_call(
self,
request: ModelRequest,
handler: Callable[[ModelRequest], ModelResponse],
) -> ExtendedModelResponse:
response = handler(request)
return ExtendedModelResponse(
model_response=response,
command=Command(update={"custom_key": "custom_value"}),
)
class CustomState(AgentState):
custom_key: str
model = GenericFakeChatModel(messages=iter([AIMessage(content="Hello")]))
agent = create_agent(
model=model,
middleware=[CustomFieldMiddleware()],
state_schema=CustomState,
)
result = agent.invoke({"messages": [HumanMessage("Hi")]})
assert result["messages"][-1].content == "Hello"
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does test_command_with_custom_state_field() do?
test_command_with_custom_state_field() is a function in the langchain codebase, defined in libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_wrap_model_call_state_update.py.
Where is test_command_with_custom_state_field() defined?
test_command_with_custom_state_field() is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_wrap_model_call_state_update.py at line 115.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free