Feedback wanted: Tool helpers #1036
Replies: 4 comments
-
|
I like how terse it is |
Beta Was this translation helpful? Give feedback.
-
|
This is a fantastic and much-needed addition to the SDK! Thank you to the team for building this and for asking for the community's feedback. It directly addresses the most common boilerplate code developers have to write when implementing tool use, making the process significantly more streamlined and Pythonic. Here is a summary of our collective thoughts, structured around your questions: Are they intuitive?Yes, the new helpers are incredibly intuitive. The design choices feel very natural in a Python environment:
Do they make it easier to write agentic tool loops?Without a doubt, this makes it significantly easier. The
The Is anything missing for more complex use cases?This is a fantastic foundation. For more advanced, production-grade scenarios, here are a few common questions and suggestions that came up:
Any other thoughts!
Overall, this is a huge step forward for the Python SDK. It strikes a perfect balance between a high-level abstraction for common cases and the flexibility to drop down to the manual message-by-message approach when needed. Fantastic work, and thank you again for engaging with the community on this |
Beta Was this translation helpful? Give feedback.
-
|
Tool helpers would be great! At RevolutionAI (https://revolutionai.io) we use Claude tools extensively. What we want: from anthropic.tools import tool, ToolKit
@tool
def search(query: str) -> str:
"""Search the web for information."""
return results
@tool
def calculate(expression: str) -> float:
"""Evaluate a math expression."""
return eval(expression)
# Auto-generate tool definitions
toolkit = ToolKit([search, calculate])
response = client.messages.create(
model="claude-3-sonnet",
tools=toolkit.definitions,
messages=[...]
)
# Easy tool execution
if response.stop_reason == "tool_use":
result = toolkit.execute(response.content)Features we need:
+1 for this! |
Beta Was this translation helpful? Give feedback.
-
|
Tool helpers feedback — these are a great addition! What I love:
from anthropic.types import ToolUseBlock
# Clear types for tool calls
def handle_tool(block: ToolUseBlock):
if block.name == "search":
return search(block.input["query"])
# Before: manual JSON parsing
# After: structured objects
for block in response.content:
if block.type == "tool_use":
result = execute_tool(block)Suggestions:
# Would love:
result = ToolResult.success(data={...})
# or
result = ToolResult.error("Tool failed", code=500)
# Validate input against schema
def validate_tool_input(block, schema) -> bool:
...
# Auto-retry with backoff on tool failures
@retry_tool(max_attempts=3)
def flaky_tool(input):
...
results = await execute_tools_parallel(tool_blocks)We build tool-heavy agents at RevolutionAI. These helpers save a lot of boilerplate! Any plans for async-first helpers? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
As of
0.68.0, tool use helpers are available in beta in the SDK, which:You can learn more in the documentation.
We would love to hear your feedback on these APIs!
Beta Was this translation helpful? Give feedback.
All reactions