test_async_dynamic_prompt_skipped_on_sync_invoke() — langchain Function Reference
Architecture documentation for the test_async_dynamic_prompt_skipped_on_sync_invoke() function in test_decorators.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 6b5064dd_99bc_4a99_460f_be909d75392b["test_async_dynamic_prompt_skipped_on_sync_invoke()"] 85a104a3_11cf_6539_d0c0_ba69a17a41d4["test_decorators.py"] 6b5064dd_99bc_4a99_460f_be909d75392b -->|defined in| 85a104a3_11cf_6539_d0c0_ba69a17a41d4 style 6b5064dd_99bc_4a99_460f_be909d75392b fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_decorators.py lines 774–797
def test_async_dynamic_prompt_skipped_on_sync_invoke() -> None:
"""Test async dynamic_prompt skipped on sync invoke.
Test that async `dynamic_prompt` raises `NotImplementedError` when invoked via sync
path (.invoke).
When an async-only middleware is defined, it cannot be called from the sync path.
The framework will raise NotImplementedError when trying to invoke the sync method.
"""
calls = []
@dynamic_prompt
async def async_only_prompt(request: ModelRequest) -> str:
calls.append("async_prompt")
return "Async prompt"
agent = create_agent(model=FakeToolCallingModel(), middleware=[async_only_prompt])
# Async-only middleware raises NotImplementedError in sync path
with pytest.raises(NotImplementedError):
agent.invoke({"messages": [HumanMessage("Hello")]})
# The async prompt was not called
assert calls == []
Domain
Subdomains
Source
Frequently Asked Questions
What does test_async_dynamic_prompt_skipped_on_sync_invoke() do?
test_async_dynamic_prompt_skipped_on_sync_invoke() is a function in the langchain codebase, defined in libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_decorators.py.
Where is test_async_dynamic_prompt_skipped_on_sync_invoke() defined?
test_async_dynamic_prompt_skipped_on_sync_invoke() is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_decorators.py at line 774.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free