Skip to content

Add builtin_tools to Agent #1722

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

Draft
wants to merge 21 commits into
base: main
Choose a base branch
from
Draft

Add builtin_tools to Agent #1722

wants to merge 21 commits into from

Conversation

Kludex
Copy link
Member

@Kludex Kludex commented May 14, 2025

No description provided.

Comment on lines +345 to +349
for tool in builtin_tools:
if tool == 'web-search':
self._builtin_tools.append(WebSearchTool())
else:
self._builtin_tools.append(tool)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's easier to not have to handle string on the models, so we already do the transformation here.

"""


class UserLocation(TypedDict, total=False):
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's easier to handle this in the models if it's a TypedDict, since it matches the type.

Comment on lines +33 to +34
@dataclass
class WebSearchTool(AbstractBuiltinTool):
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the DX POV, it's nicer for it to be a BaseModel or dataclass.

Copy link

github-actions bot commented May 14, 2025

Docs Preview

commit: 5f89444
Preview URL: https://2a7ce196-pydantic-ai-previews.pydantic.workers.dev

Comment on lines 622 to +623
tools = list(model_settings.get('openai_builtin_tools', [])) + tools
tools = self._get_builtin_tools(model_request_parameters) + tools
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should deprecate the openai_builtin_tools in this PR.

class AbstractBuiltinTool(ABC):
"""A builtin tool that can be used by an agent.

This class is abstract and cannot be instantiated directly.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think worth including a sentence here explaining how the code execution works to make use of them — something like "these are passed to the model as part of the ModelRequestParameters" or whatever. (Not sure if that's true, haven't gotten there yet ..). But I imagine it helping someone who is trying to figure out how they are different from normal tools.

Copy link
Contributor

@dmontagu dmontagu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM other than tests and docs

@Kludex Kludex marked this pull request as draft May 15, 2025 16:09
Copy link
Contributor

hyperlint-ai bot commented May 30, 2025

PR Change Summary

Enhanced documentation for the Agent class and its output handling, including updates on transport methods and output functions.

  • Updated transport method descriptions for MCPServerHTTP to reflect the Streamable HTTP transport.
  • Clarified the use of output functions and their role in agent runs.
  • Added examples demonstrating the use of output functions and structured outputs.

Modified Files

  • docs/mcp/client.md
  • docs/multi-agent-applications.md
  • docs/output.md
  • docs/tools.md

How can I customize these reviews?

Check out the Hyperlint AI Reviewer docs for more information on how to customize the review.

If you just want to ignore it on this PR, you can add the hyperlint-ignore label to the PR. Future changes won't trigger a Hyperlint review.

Note specifically for link checks, we only check the first 30 links in a file and we cache the results for several hours (for instance, if you just added a page, you might experience this). Our recommendation is to add hyperlint-ignore to the PR to ignore the link check for this PR.

@Kludex Kludex force-pushed the add-builtin-tools branch from 65fa051 to 5f89444 Compare June 1, 2025 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants