Home / Function/ on_tool_start() — langchain Function Reference

on_tool_start() — langchain Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  6e8e2bcc_e323_48a9_ae97_c42e87df1432["on_tool_start()"]
  b06b8501_4df8_c912_9b4d_ff89356d0361["CallbackHandlerWithToolCallIdCapture"]
  6e8e2bcc_e323_48a9_ae97_c42e87df1432 -->|defined in| b06b8501_4df8_c912_9b4d_ff89356d0361
  d42476ff_6b17_148a_8f54_3942b7d71a6e["on_tool_start()"]
  d42476ff_6b17_148a_8f54_3942b7d71a6e -->|calls| 6e8e2bcc_e323_48a9_ae97_c42e87df1432
  d42476ff_6b17_148a_8f54_3942b7d71a6e["on_tool_start()"]
  6e8e2bcc_e323_48a9_ae97_c42e87df1432 -->|calls| d42476ff_6b17_148a_8f54_3942b7d71a6e
  style 6e8e2bcc_e323_48a9_ae97_c42e87df1432 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/tests/unit_tests/test_tools.py lines 3323–3362

    def on_tool_start(
        self,
        serialized: dict[str, Any],
        input_str: str,
        *,
        run_id: Any,
        parent_run_id: Any | None = None,
        tags: list[str] | None = None,
        metadata: dict[str, Any] | None = None,
        inputs: dict[str, Any] | None = None,
        tool_call_id: str | None = None,
        **kwargs: Any,
    ) -> Any:
        """Capture the `tool_call_id` passed to `on_tool_start`.

        Args:
            serialized: Serialized tool information.
            input_str: String representation of tool input.
            run_id: Unique identifier for this run.
            parent_run_id: Identifier of the parent run.
            tags: Optional tags for this run.
            metadata: Optional metadata for this run.
            inputs: Dictionary of tool inputs.
            tool_call_id: The tool call identifier from the LLM.
            **kwargs: Additional keyword arguments.

        Returns:
            Result from parent `on_tool_start` call.
        """
        self.captured_tool_call_ids.append(tool_call_id)
        return super().on_tool_start(
            serialized,
            input_str,
            run_id=run_id,
            parent_run_id=parent_run_id,
            tags=tags,
            metadata=metadata,
            inputs=inputs,
            **kwargs,
        )

Domain

Subdomains

Called By

Frequently Asked Questions

What does on_tool_start() do?
on_tool_start() is a function in the langchain codebase, defined in libs/core/tests/unit_tests/test_tools.py.
Where is on_tool_start() defined?
on_tool_start() is defined in libs/core/tests/unit_tests/test_tools.py at line 3323.
What does on_tool_start() call?
on_tool_start() calls 1 function(s): on_tool_start.
What calls on_tool_start()?
on_tool_start() is called by 1 function(s): on_tool_start.

Analyze Your Own Codebase

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

Try Supermodel Free