ToolEnabledConversation
Extend Conversation with automatic tool invocation support.
Usage
ToolEnabledConversation()ToolEnabledConversation inherits every feature of Conversation and adds the ability to discover, invoke, and record tool calls. When auto_tools is True, the conversation can automatically match user requests to registered tools and inject tool results back into the message history.
Parameters
conversation_id: Optional[str] = None-
Optional identifier for this conversation. Generated automatically when
None. tool_registry: Optional[ToolRegistry] = None-
The
ToolRegistrythat holds available tools. WhenNonethe global registry returned by get_global_registry() is used. auto_tools: bool = True-
If
True(the default), the conversation may invoke tools automatically when a matching tool is found for a user message. tool_confirmation: bool = False-
If
True, prompt the user for confirmation before executing any tool. Defaults toFalse.
Examples
Create a tool-enabled conversation and list available tools:
import talk_box as tb
conv = tb.ToolEnabledConversation()
conv.get_available_tools()Use the convenience factory instead:
conv = tb.create_tool_conversation()Methods
| Name | Description |
|---|---|
| add_tool_call_message() | Add a tool call result as a message to the conversation. |
| create_tool_context() | Create a rich ToolContext from the conversation state. |
| get_available_tools() | Get tools available for this conversation. |
add_tool_call_message()
Add a tool call result as a message to the conversation.
Usage
add_tool_call_message(tool_name, parameters, result, success=True, error=None)create_tool_context()
Create a rich ToolContext from the conversation state.
Usage
create_tool_context(user_id=None, session_id=None, extra_metadata=None)get_available_tools()
Get tools available for this conversation.
Usage
get_available_tools(category=None)