Home / Function/ _on_chain_start() — langchain Function Reference

_on_chain_start() — langchain Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  522bf4a7_0f10_4669_22e7_ff30c35a9f71["_on_chain_start()"]
  178590bb_85ff_b79e_979a_46e5c3c5389f["LangChainTracer"]
  522bf4a7_0f10_4669_22e7_ff30c35a9f71 -->|defined in| 178590bb_85ff_b79e_979a_46e5c3c5389f
  cf43defe_cb35_deb4_9782_55f973cdf6ca["_persist_run_single()"]
  522bf4a7_0f10_4669_22e7_ff30c35a9f71 -->|calls| cf43defe_cb35_deb4_9782_55f973cdf6ca
  style 522bf4a7_0f10_4669_22e7_ff30c35a9f71 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/langchain_core/tracers/langchain.py lines 319–326

    def _on_chain_start(self, run: Run) -> None:
        """Process the Chain Run upon start."""
        if run.parent_run_id is None:
            run.reference_example_id = self.example_id
        # Skip persisting if inputs are deferred (e.g., iterator/generator inputs).
        # The run will be posted when _on_chain_end is called with realized inputs.
        if not run.extra.get("defers_inputs"):
            self._persist_run_single(run)

Domain

Subdomains

Frequently Asked Questions

What does _on_chain_start() do?
_on_chain_start() is a function in the langchain codebase, defined in libs/core/langchain_core/tracers/langchain.py.
Where is _on_chain_start() defined?
_on_chain_start() is defined in libs/core/langchain_core/tracers/langchain.py at line 319.
What does _on_chain_start() call?
_on_chain_start() calls 1 function(s): _persist_run_single.

Analyze Your Own Codebase

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

Try Supermodel Free