Summary audio
Spoken summary — press play to read along: the line being spoken stays near the top.
Study notes
Key Concepts: Integrating Tools with Claude
**1. Tool Integration Process**
- To enable tool use, the server sends a request to Claude that includes:
- The user's message.
- A tools keyword argument, which is a list containing the JSON schema specifications for available tools (e. g. , get current datetime schema).
**2. Multi-Block Messages**
- When Claude decides to use a tool, the response is not a simple text block. It is an assistant message containing a list of content blocks.
- A message can contain multiple blocks, which include:
- Text Block: Contains natural language intended for the user (e. g. , "I can help you find the current time... ").
- Tool Use Block: Instructed to the developer that Claude wants to execute a specific tool. This block lists the tool function name and the required arguments/inputs.
**3. Conversation History Management**
- Manual Management: Claude does not inherently store conversation history. Developers must manage and provide the entire conversation history manually in every subsequent request.
- Handling Multi-Block History: When building the conversation history, it is critical to include the entire content of the response, not just the text. This means including all blocks (text blocks and tool use blocks) from the assistant's response.
- System Updates: Helper functions (like add user message and add assistant message) must be updated to correctly handle and store messages that contain multiple content blocks.
Takeaways
- Tool integration requires sending the user message along with a tools argument containing the JSON schema specifications for available functions.
- When a tool is used, Claude responds with a multi-block message containing both natural language (Text Block) and the specific function call (Tool Use Block).
- Developers must manually manage the entire conversation history, as Claude does not store history inherently.
- When updating the conversation history, it is critical to include all content blocks (text and tool use) from the assistant's response, not just the text.
Flashcards 9 cards
Question
click to reveal · ←/→
Answer
click to flip back
Knowledge check 1 questions