-
Notifications
You must be signed in to change notification settings - Fork 2k
New Tools: HTTP pre-built tools #3944
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| """Make HTTP request with given parameters. | ||
|
|
||
| Args: | ||
| url: Endpoint URL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in agent builder work I found that it's a must-have to support templating arguments into named path segments if this is going to work for any REST API. so this shouldn't be an actual URL but should be a URL template, and we'd need a way to partition the passed arguments into those that go into the URL and those that go into the payload
| parameters={ | ||
| "type": "object", | ||
| "properties": { | ||
| "city": {"type": "string"} | ||
| }, | ||
| "required": ["city"] | ||
| }, | ||
| output_normalizer=lambda resp: f"Temp: {resp.body}" if resp.success else None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this syntax seems pretty verbose - i wonder if there's a more pythonic way to do it?
| timeout_ms: Request timeout in milliseconds (default: 30000) | ||
| parameters: JSON schema dict for tool parameters (defaults to empty object schema) | ||
| execution_message: Optional message to announce before executing (spoken by agent) | ||
| output_normalizer: Optional function to transform HTTPResponse to string or None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rather than adding additional complexity to the tool - it may be better to create two layers of abstraction:
- a simplified utility for performing a URL request from a tool call that handles variable templating and errors consistently, and could be used inside any function_tool
- a tool factory method that takes an HTTP config and outputs a simple tool using the aforementioned utility
this way devs could add any kind of before/after customization they need by leveraging the lower-level utility, but we'd still offer a no-frills basic wrapper
| if method == "GET": | ||
| resp_ctx = session.get(url, params=arguments, headers=headers) | ||
| elif method == "POST": | ||
| resp_ctx = session.post(url, json=arguments, headers=headers) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you need to context.disallow_interruptions() for anything besides a GET request, since these aren't otherwise cancelable
so now you can either pass a full json_schema dict for complete control, or a shorthand params list (HTTPToolParam) for common string/enum/int/bool cases - the factory turns both into the same schema before validation. |
I'd like to propose two new beta tools that address common patterns I've seen when building voice agents.
1. SMS Tool - Many voice agents need to send text messages during calls (order confirmations, addresses, booking links, etc.). This tool provides a simple way to send SMS via Twilio, SignalWire, or Vonage. It can auto-detect the caller's phone number from the SIP session or use pre-configured recipients. The goal is to reduce boilerplate for this common use case while keeping it flexible enough for different workflows.UPD: SMS tools moved to another branch to separate discussion
HTTP Tool - A lot of agents need to call external APIs - webhooks, CRMs, internal services, etc. Rather than writing custom functions for each HTTP call, this tool lets you declaratively configure requests with parameters, headers, timeouts, and response handling. The idea is to make simple API integrations faster to implement while still supporting customization when needed.
Both tools include error handling, provider auto-detection (SMS), and parameter validation. I've included tests and an example with the weather agent showing how they work together.
Open to feedback on the API design, naming, and what additional features might be useful!