Skip to content

Feat/OpenAI agent builtin tools 6657 #6671

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

Open
wants to merge 34 commits into
base: main
Choose a base branch
from

Conversation

tejas-dharani
Copy link
Contributor

@tejas-dharani tejas-dharani commented Jun 12, 2025

Why are these changes needed?

This PR adds comprehensive built-in tool support to OpenAIAgent, enabling support for file_search, code_interpreter, web_search_preview, computer_use_preview, image_generation, local_shell and mcp tools. The changes include comprehensive testing for all tool types including mixed usage scenarios, working examples demonstrating tool usage, updated documentation with version notes and usage examples, while maintaining backward compatibility with existing function tools.

Related issue number

Fixes #6657

Checks

…on guide- Fix version format from 0.4.0-dev-1 to 0.4.0-dev.1 for all packages- Remove reference to non-existent Microsoft.AutoGen.Extensions package- Add correct extension packages: Aspire, MEAI, and SemanticKernel- Fix typo: RuntimeGatewway -> RuntimeGateway- Improve documentation structure with clear section headersFixes microsoft#6244
Fix issue microsoft#6277 where TextMessage was used but not imported in three code cells
of the custom agents documentation, causing NameError when users run the examples.

Changes:
- Add TextMessage to imports in ArithmeticAgent section
- Add TextMessage to imports in GeminiAssistantAgent section
- Add TextMessage to imports in Declarative GeminiAssistantAgent section

The CountDownAgent section already had the correct import.

Fixes microsoft#6277
- Support file_search, code_interpreter, web_search_preview, computer_use_preview, image_generation, and mcp tools
- Add comprehensive tests for all tool types including mixed usage scenarios
- Include working examples demonstrating tool usage
- Update documentation with version notes and usage examples
- Maintain backward compatibility with existing function tools

Fixes microsoft#6657
@victordibia
Copy link
Collaborator

@withsmilo
Hi Sungjun,

Would you mid providing a first review here?

@withsmilo
Copy link
Contributor

Sure. Let me review today night.

Copy link

codecov bot commented Jun 14, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.00%. Comparing base (3436ec2) to head (05f60d6).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6671      +/-   ##
==========================================
+ Coverage   79.74%   80.00%   +0.25%     
==========================================
  Files         232        1     -231     
  Lines       17403      150   -17253     
==========================================
- Hits        13878      120   -13758     
+ Misses       3525       30    -3495     
Flag Coverage Δ
unittests ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

dotnet add package Microsoft.AutoGen.AgentChat --version 0.4.0-dev-1
dotnet add package Microsoft.AutoGen.Agents --version 0.4.0-dev-1
dotnet add package Microsoft.AutoGen.Extensions --version 0.4.0-dev-1
dotnet add package Microsoft.AutoGen.AgentChat --version 0.4.0-dev.1
Copy link
Collaborator

@victordibia victordibia Jun 14, 2025

Choose a reason for hiding this comment

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

@tejas-dharani ,
Changes should be scoped to the PR title/focus
This file is unrelated to the OpenAI agent

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @victordibia,
You're absolutely right - my apologies for the confusion.
My mistake was that after forking the repo, I raised my first PR (the .NET correction) directly from the main branch instead of creating a separate branch. After that, I created separate branches for all other issues, but now this .NET change is affecting every subsequent PR since they're all based off my modified main branch.
I understand this file is unrelated to the OpenAI agent work. I'll close the .NET PR to keep it separate from the OpenAI agent changes.
Thanks for catching this - lesson learned about proper Git workflow!

@@ -0,0 +1,231 @@
"""
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ideally, this file should be removed.
Please follow convention - examples should be in the docstrings

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, Sure

Iterable[
Union[
Literal[
"file_search",
Copy link
Contributor

@withsmilo withsmilo Jun 15, 2025

Choose a reason for hiding this comment

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

Hi @tejas-dharani .
According to the official doc, the Responses API supports 7 built-in tools as well as function calls. However, I found your PR omitted one built-in tool (local_shell) and lots of "required" parameters to execute built-in tools. Could you please check the official doc in detail once more?

  1. file_search

    1. vector_store_ids (required)
    2. filters
    3. max_num_results
    4. ranking_options
  2. web_search_preview

    1. search_context_size
    2. user_location
  3. computer_use_preview

    1. display_height (required)
    2. display_width (required)
    3. environment (required)
  4. mcp

    1. server_label (required)
    2. server_url (required)
    3. allowed_tools
    4. headers
    5. require_approval
  5. code_interpreter

    1. container (required)
  6. image_generation

    1. background
    2. input_image_mask
    3. ....
  7. local_shell

Copy link
Contributor Author

@tejas-dharani tejas-dharani Jun 16, 2025

Choose a reason for hiding this comment

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

Hi @withsmilo,
Thank you for the detailed feedback! I missed required parameters for each tool type.

I'll address:
Implement all required parameters (vector_store_ids, display dimensions, container, server configs, etc.)
Add proper parameter validation and type hints
Fix the failing mypy/pyright checks

Will research the official docs more thoroughly for the complete specifications.
Thanks for the thorough review!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@withsmilo
I don't find the local_shell , are you refering to function calling ? Function calling is already there.
https://platform.openai.com/docs/guides/tools?api-mode=responses

Choose a reason for hiding this comment

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

Hi @tejas-dharani , I compared the available tools present in the openai docs with the ones added in the PR. What I think @withsmilo is mentioning is that the local shell tool has not been implemented.

Copy link
Contributor Author

@tejas-dharani tejas-dharani Jun 16, 2025

Choose a reason for hiding this comment

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

I see now, local shell tool is missing in Available tools openai docs.

Also Local shell is available through the Responses API for use with codex-mini-latest. It is not available on other models.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hello @withsmilo Sir,

Can you please review the changes again ? I have made necessory changes.

…stallation guide- Fix version format from 0.4.0-dev-1 to 0.4.0-dev.1 for all packages- Remove reference to non-existent Microsoft.AutoGen.Extensions package- Add correct extension packages: Aspire, MEAI, and SemanticKernel- Fix typo: RuntimeGatewway -> RuntimeGateway- Improve documentation structure with clear section headersFixes microsoft#6244"

This reverts commit 6d9fb2e.
assert (
incorrect_code_result in message.to_text().strip()
), f"Expected {incorrect_code_result} in execution result, got: {message.to_text().strip()}"
"mean = sum(numbers) / len(numbers" in execution_text
Copy link
Contributor

Choose a reason for hiding this comment

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

Hi, @tejas-dharani .
Why did you update this file? it seems this change is not related with your PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi, @withsmilo ,

It was changes because it shows poe error, but i have reverted it because it is not related to this PR.

@@ -16,6 +16,7 @@ classifiers = [
]
dependencies = [
"autogen-core==0.6.1",
"typing_extensions",
Copy link
Contributor

@withsmilo withsmilo Jun 24, 2025

Choose a reason for hiding this comment

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

This is unnecessary because autogen-core package already has a "typing-extensions>=4.0.0" dependency (link) and autogen-ext is using autogen-core now (link).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I will remove it. Thanks for guiding me.

Copy link
Collaborator

@ekzhu ekzhu left a comment

Choose a reason for hiding this comment

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

Thanks for the PR:

  1. Can you add support for built in tools for the JSON config (ie _to_config and _from_config).
  2. Can you add integration tests that hits the actual model api, trigger only when open ai key is in the environment.

print(response)

asyncio.run(example())

.. versionchanged:: v0.4.1
Copy link
Collaborator

Choose a reason for hiding this comment

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

Version is incorrect

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Corrected Sir.

@tejas-dharani
Copy link
Contributor Author

Thanks for the PR:

  1. Can you add support for built in tools for the JSON config (ie _to_config and _from_config).
  2. Can you add integration tests that hits the actual model api, trigger only when open ai key is in the environment.

Hello Sir,

I have implemented the recommended changes:

  • Added support for built-in tools in the JSON config (_to_config and _from_config).
  • Added integration tests that call the actual model API, which are triggered only when an OpenAI key is present in the environment.

Please let me know if anything else is needed.

@tejas-dharani tejas-dharani requested a review from ekzhu June 28, 2025 07:35
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.

OpenAIAgent should support other tool types as well as function
5 participants