-
Notifications
You must be signed in to change notification settings - Fork 1k
Python: Create/Get Agent API for OpenAI Assistants #3208
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
Python: Create/Get Agent API for OpenAI Assistants #3208
Conversation
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.
Pull request overview
This PR introduces a new OpenAIAssistantProvider class that provides a clean, provider-based API for creating and managing OpenAI Assistant agents. This implements Option 2 from ADR #2618, offering three key methods: create_agent() to create new assistants, get_agent() to retrieve existing assistants by ID, and as_agent() to wrap SDK Assistant objects without additional HTTP calls.
Changes:
- Added
OpenAIAssistantProviderclass with create/get/as_agent methods - Refactored tool conversion utilities to shared module for reuse
- Updated all OpenAI Assistants samples to use the new provider API
- Added comprehensive unit tests for the provider
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
python/packages/core/agent_framework/openai/_assistant_provider.py |
New provider class with create_agent, get_agent, and as_agent methods |
python/packages/core/agent_framework/openai/_shared.py |
Added tool conversion utilities (to_assistant_tools, from_assistant_tools) |
python/packages/core/agent_framework/openai/_assistants_client.py |
Refactored to use shared tool conversion utilities |
python/packages/core/agent_framework/openai/__init__.py |
Exports the new OpenAIAssistantProvider |
python/packages/core/tests/openai/test_assistant_provider.py |
Comprehensive unit tests covering all provider functionality |
python/samples/getting_started/agents/openai/openai_assistants_basic.py |
Updated to use provider API |
python/samples/getting_started/agents/openai/openai_assistants_provider_methods.py |
New sample demonstrating all provider methods |
python/samples/getting_started/agents/openai/openai_assistants_with_response_format.py |
New sample showing structured output with response_format |
python/samples/getting_started/agents/openai/openai_assistants_with_thread.py |
Updated to use provider API |
python/samples/getting_started/agents/openai/openai_assistants_with_function_tools.py |
Updated to use provider API |
python/samples/getting_started/agents/openai/openai_assistants_with_file_search.py |
Updated to use provider API |
python/samples/getting_started/agents/openai/openai_assistants_with_code_interpreter.py |
Updated to use provider API |
python/samples/getting_started/agents/openai/openai_assistants_with_explicit_settings.py |
Updated to use provider API |
python/samples/getting_started/agents/openai/openai_assistants_with_existing_assistant.py |
Updated to demonstrate get_agent and as_agent methods |
python/samples/getting_started/agents/openai/README.md |
Updated documentation for all samples |
Python Test Coverage Report •
Python Unit Test Overview
|
|||||||||||||||||||||||||||||||||||
Motivation and Context
This PR contains an implementation of create/get API with
Providertype for OpenAI Assistants chat client, based on Option 2 from this ADR.Example:
Contribution Checklist