Class ToolContext

java.lang.Object
org.springframework.ai.chat.model.ToolContext

public class ToolContext extends Object
Represents the context for tool execution in a function calling scenario.

This class encapsulates a map of contextual information that can be passed to tools (functions) when they are called. It provides an immutable view of the context to ensure thread-safety and prevent modification after creation.

The context is typically populated from the toolContext field of FunctionCallingOptions and is used in the function execution process.

Since:
1.0.0
Author:
Christian Tzolov
  • Constructor Details

    • ToolContext

      public ToolContext(Map<String,Object> context)
      Constructs a new ToolContext with the given context map.
      Parameters:
      context - A map containing the tool context information. This map is wrapped in an unmodifiable view to prevent changes.
  • Method Details

    • getContext

      public Map<String,Object> getContext()
      Returns the immutable context map.
      Returns:
      An unmodifiable view of the context map.