Home / Class/ CallbackHandlerWithToolCallIdCapture Class — langchain Architecture

CallbackHandlerWithToolCallIdCapture Class — langchain Architecture

Architecture documentation for the CallbackHandlerWithToolCallIdCapture class in test_tools.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  b06b8501_4df8_c912_9b4d_ff89356d0361["CallbackHandlerWithToolCallIdCapture"]
  9659be4f_91d1_3b62_bcfb_38c048777165["FakeCallbackHandler"]
  b06b8501_4df8_c912_9b4d_ff89356d0361 -->|extends| 9659be4f_91d1_3b62_bcfb_38c048777165
  8e7836ae_e72c_f670_72a5_4ca6d46e3555["test_tools.py"]
  b06b8501_4df8_c912_9b4d_ff89356d0361 -->|defined in| 8e7836ae_e72c_f670_72a5_4ca6d46e3555
  6e8e2bcc_e323_48a9_ae97_c42e87df1432["on_tool_start()"]
  b06b8501_4df8_c912_9b4d_ff89356d0361 -->|method| 6e8e2bcc_e323_48a9_ae97_c42e87df1432

Relationship Graph

Source Code

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

class CallbackHandlerWithToolCallIdCapture(FakeCallbackHandler):
    """Callback handler that captures `tool_call_id` passed to `on_tool_start`.

    Used to verify that `tool_call_id` is correctly forwarded to the `on_tool_start`
    callback method.
    """

    captured_tool_call_ids: list[str | None] = Field(default_factory=list)

    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,
        )

Frequently Asked Questions

What is the CallbackHandlerWithToolCallIdCapture class?
CallbackHandlerWithToolCallIdCapture is a class in the langchain codebase, defined in libs/core/tests/unit_tests/test_tools.py.
Where is CallbackHandlerWithToolCallIdCapture defined?
CallbackHandlerWithToolCallIdCapture is defined in libs/core/tests/unit_tests/test_tools.py at line 3314.
What does CallbackHandlerWithToolCallIdCapture extend?
CallbackHandlerWithToolCallIdCapture extends FakeCallbackHandler.

Analyze Your Own Codebase

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

Try Supermodel Free