test_decorator_request_modification() — langchain Function Reference
Architecture documentation for the test_decorator_request_modification() function in test_wrap_model_call.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 01a8a096_f4d1_7e5f_d3e6_4bccd4a74c61["test_decorator_request_modification()"] 5a3c6db0_0302_046a_d217_22fb3d4e632e["TestWrapModelCallDecorator"] 01a8a096_f4d1_7e5f_d3e6_4bccd4a74c61 -->|defined in| 5a3c6db0_0302_046a_d217_22fb3d4e632e style 01a8a096_f4d1_7e5f_d3e6_4bccd4a74c61 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_wrap_model_call.py lines 1348–1376
def test_decorator_request_modification(self) -> None:
"""Test decorator modifying request before execution."""
modified_prompts = []
@wrap_model_call
def add_system_prompt(
request: ModelRequest,
handler: Callable[[ModelRequest], ModelResponse],
) -> ModelCallResult:
# Modify request to add system prompt
modified_request = ModelRequest(
messages=request.messages,
model=request.model,
system_prompt="You are a helpful assistant",
tool_choice=request.tool_choice,
tools=request.tools,
response_format=request.response_format,
state=AgentState[Any](messages=[]),
runtime=None,
)
modified_prompts.append(modified_request.system_prompt)
return handler(modified_request)
model = GenericFakeChatModel(messages=iter([AIMessage(content="Response")]))
agent = create_agent(model=model, middleware=[add_system_prompt])
agent.invoke({"messages": [HumanMessage("Test")]})
assert modified_prompts == ["You are a helpful assistant"]
Domain
Subdomains
Source
Frequently Asked Questions
What does test_decorator_request_modification() do?
test_decorator_request_modification() is a function in the langchain codebase, defined in libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_wrap_model_call.py.
Where is test_decorator_request_modification() defined?
test_decorator_request_modification() is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_wrap_model_call.py at line 1348.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free