Home / Function/ test_after_model_decorator() — langchain Function Reference

test_after_model_decorator() — langchain Function Reference

Architecture documentation for the test_after_model_decorator() function in test_decorators.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  16ca7528_7a30_3e96_9e48_703331613607["test_after_model_decorator()"]
  85a104a3_11cf_6539_d0c0_ba69a17a41d4["test_decorators.py"]
  16ca7528_7a30_3e96_9e48_703331613607 -->|defined in| 85a104a3_11cf_6539_d0c0_ba69a17a41d4
  5db83528_8e08_d7fe_e2fc_f806b038e621["after_model()"]
  16ca7528_7a30_3e96_9e48_703331613607 -->|calls| 5db83528_8e08_d7fe_e2fc_f806b038e621
  style 16ca7528_7a30_3e96_9e48_703331613607 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_decorators.py lines 69–95

def test_after_model_decorator() -> None:
    """Test after_model decorator with all configuration options."""

    @after_model(
        state_schema=CustomState,
        tools=[test_tool],
        can_jump_to=["model", "end"],
        name="CustomAfterModel",
    )
    def custom_after_model(*_args: Any, **_kwargs: Any) -> dict[str, Any]:
        return {"jump_to": "model"}

    # Verify all options were applied
    assert isinstance(custom_after_model, AgentMiddleware)
    assert custom_after_model.state_schema == CustomState
    assert custom_after_model.tools == [test_tool]
    assert getattr(custom_after_model.__class__.after_model, "__can_jump_to__", []) == [
        "model",
        "end",
    ]
    assert custom_after_model.__class__.__name__ == "CustomAfterModel"

    # Verify it works
    result = custom_after_model.after_model(
        {"messages": [HumanMessage("Hello"), AIMessage("Hi!")]}, Runtime()
    )
    assert result == {"jump_to": "model"}

Domain

Subdomains

Frequently Asked Questions

What does test_after_model_decorator() do?
test_after_model_decorator() is a function in the langchain codebase, defined in libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_decorators.py.
Where is test_after_model_decorator() defined?
test_after_model_decorator() is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_decorators.py at line 69.
What does test_after_model_decorator() call?
test_after_model_decorator() calls 1 function(s): after_model.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free