test_command_with_extra_messages_and_model_response() — langchain Function Reference
Architecture documentation for the test_command_with_extra_messages_and_model_response() function in test_wrap_model_call_state_update.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD dd6f5635_507b_9aec_47c5_038caeb19080["test_command_with_extra_messages_and_model_response()"] 32ccf275_216c_0c5f_4a10_07f3bc9d69a5["TestBasicCommand"] dd6f5635_507b_9aec_47c5_038caeb19080 -->|defined in| 32ccf275_216c_0c5f_4a10_07f3bc9d69a5 style dd6f5635_507b_9aec_47c5_038caeb19080 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 57–82
def test_command_with_extra_messages_and_model_response(self) -> None:
"""Middleware can add extra messages via command alongside model messages."""
class ExtraMessagesMiddleware(AgentMiddleware):
def wrap_model_call(
self,
request: ModelRequest,
handler: Callable[[ModelRequest], ModelResponse],
) -> ExtendedModelResponse:
response = handler(request)
summary = HumanMessage(content="Summary", id="summary")
return ExtendedModelResponse(
model_response=response,
command=Command(update={"messages": [summary]}),
)
model = GenericFakeChatModel(messages=iter([AIMessage(content="Hello!")]))
agent = create_agent(model=model, middleware=[ExtraMessagesMiddleware()])
result = agent.invoke({"messages": [HumanMessage(content="Hi")]})
messages = result["messages"]
assert len(messages) == 3
assert messages[0].content == "Hi"
assert messages[1].content == "Hello!"
assert messages[2].content == "Summary"
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does test_command_with_extra_messages_and_model_response() do?
test_command_with_extra_messages_and_model_response() 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_extra_messages_and_model_response() defined?
test_command_with_extra_messages_and_model_response() is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_wrap_model_call_state_update.py at line 57.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free