Home / Function/ before_model() — langchain Function Reference

before_model() — langchain Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  68028dcd_ea5b_7d3a_0d75_c9ebd1cef92b["before_model()"]
  cd353dda_0cce_b520_4569_96a6f4d126f2["JumpMiddleware"]
  68028dcd_ea5b_7d3a_0d75_c9ebd1cef92b -->|defined in| cd353dda_0cce_b520_4569_96a6f4d126f2
  28fa7487_7074_9d90_d3ef_bb64640336d2["before_model()"]
  28fa7487_7074_9d90_d3ef_bb64640336d2 -->|calls| 68028dcd_ea5b_7d3a_0d75_c9ebd1cef92b
  a41af999_9f1d_2536_5593_c14c9b89179f["test_before_model_decorator()"]
  a41af999_9f1d_2536_5593_c14c9b89179f -->|calls| 68028dcd_ea5b_7d3a_0d75_c9ebd1cef92b
  a07be0fe_4b9e_17f0_8a15_c277b29b23dc["test_hook_config_decorator_on_class_method()"]
  a07be0fe_4b9e_17f0_8a15_c277b29b23dc -->|calls| 68028dcd_ea5b_7d3a_0d75_c9ebd1cef92b
  ba50c5da_b594_4007_9a20_399e93249b8a["test_can_jump_to_with_before_model_decorator()"]
  ba50c5da_b594_4007_9a20_399e93249b8a -->|calls| 68028dcd_ea5b_7d3a_0d75_c9ebd1cef92b
  c8afcff3_b937_b007_b93a_eeb95331b549["test_can_jump_to_integration()"]
  c8afcff3_b937_b007_b93a_eeb95331b549 -->|calls| 68028dcd_ea5b_7d3a_0d75_c9ebd1cef92b
  be823dae_2db1_374d_3e35_112b896bee3f["test_async_before_model_decorator()"]
  be823dae_2db1_374d_3e35_112b896bee3f -->|calls| 68028dcd_ea5b_7d3a_0d75_c9ebd1cef92b
  b94ce551_2a1c_4b68_8c26_161c8363ff80["test_mixed_sync_async_decorators()"]
  b94ce551_2a1c_4b68_8c26_161c8363ff80 -->|calls| 68028dcd_ea5b_7d3a_0d75_c9ebd1cef92b
  0957f174_bc3d_95fa_6d02_e1c321ddc1bc["test_async_before_model_preserves_can_jump_to()"]
  0957f174_bc3d_95fa_6d02_e1c321ddc1bc -->|calls| 68028dcd_ea5b_7d3a_0d75_c9ebd1cef92b
  58d6df01_ca59_3024_d92c_5c03378adcf6["test_async_can_jump_to_integration()"]
  58d6df01_ca59_3024_d92c_5c03378adcf6 -->|calls| 68028dcd_ea5b_7d3a_0d75_c9ebd1cef92b
  28fa7487_7074_9d90_d3ef_bb64640336d2["before_model()"]
  68028dcd_ea5b_7d3a_0d75_c9ebd1cef92b -->|calls| 28fa7487_7074_9d90_d3ef_bb64640336d2
  style 68028dcd_ea5b_7d3a_0d75_c9ebd1cef92b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_decorators.py lines 194–199

        def before_model(
            self, state: AgentState[Any], runtime: Runtime[None]
        ) -> dict[str, Any] | None:
            if len(state["messages"]) > 5:
                return {"jump_to": "end"}
            return None

Domain

Subdomains

Frequently Asked Questions

What does before_model() do?
before_model() is a function in the langchain codebase, defined in libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_decorators.py.
Where is before_model() defined?
before_model() is defined in libs/langchain_v1/tests/unit_tests/agents/middleware/core/test_decorators.py at line 194.
What does before_model() call?
before_model() calls 1 function(s): before_model.
What calls before_model()?
before_model() is called by 9 function(s): before_model, test_async_before_model_decorator, test_async_before_model_preserves_can_jump_to, test_async_can_jump_to_integration, test_before_model_decorator, test_can_jump_to_integration, test_can_jump_to_with_before_model_decorator, test_hook_config_decorator_on_class_method, and 1 more.

Analyze Your Own Codebase

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

Try Supermodel Free