mirror of
https://github.com/microsoft/agent-framework.git
synced 2026-06-16 21:04:09 +08:00
f79fbfa92e
* feat: add OpenAI reasoning events support with comprehensive test coverage - Implement reasoning event handling in OpenAI Responses client * Add support for ResponseReasoningTextDeltaEvent * Add support for ResponseReasoningTextDoneEvent * Add support for ResponseReasoningSummaryTextDeltaEvent * Add support for ResponseReasoningSummaryTextDoneEvent * Map all reasoning events to TextReasoningContent objects * Preserve metadata across reasoning events - Add comprehensive test coverage (5 focused test functions) * test_streaming_reasoning_text_delta_event * test_streaming_reasoning_text_done_event * test_streaming_reasoning_summary_text_delta_event * test_streaming_reasoning_summary_text_done_event * test_streaming_reasoning_events_preserve_metadata - Add sample demonstrating reasoning functionality * Shows how to enable reasoning in chat options * Demonstrates accessing reasoning content from responses - Code quality improvements * Follow existing code patterns and style guidelines * Organize imports properly * Maintain backwards compatibility * All tests pass and quality checks succeed * fix: resolve type errors and cleanup unused imports after rebase - Add proper hasattr checks for optional attributes in union types - Remove unused OpenAI event type imports - Fix line length formatting issues - Ensure type safety when accessing content attributes
f79fbfa92e
ยท
2025-09-12 12:07:49 +00:00
History
OpenAI Responses Agent Examples
This folder contains examples demonstrating different ways to create and use agents with the OpenAI Responses client from the agent_framework.openai package.
Examples
| File | Description |
|---|---|
openai_responses_client_basic.py |
The simplest way to create an agent using ChatAgent with OpenAIResponsesClient. Shows both streaming and non-streaming responses for structured response generation with OpenAI models. |
openai_responses_client_reasoning.py |
Demonstrates how to use reasoning capabilities with OpenAI agents, showing how the agent can provide detailed reasoning for its responses. |
openai_responses_client_with_explicit_settings.py |
Shows how to initialize an agent with a specific responses client, configuring settings explicitly including API key and model ID. |
openai_responses_client_with_function_tools.py |
Demonstrates how to use function tools with agents. Shows both agent-level tools (defined when creating the agent) and query-level tools (provided with specific queries). |
openai_responses_client_with_code_interpreter.py |
Shows how to use the HostedCodeInterpreterTool with OpenAI agents to write and execute Python code. Includes helper methods for accessing code interpreter data from response chunks. |
openai_responses_client_with_file_search.py |
Demonstrates how to use file search capabilities with OpenAI agents, allowing the agent to search through uploaded files to answer questions. |
openai_responses_client_with_local_mcp.py |
Shows how to integrate OpenAI agents with local Model Context Protocol (MCP) servers for enhanced functionality and tool integration. |
openai_responses_client_with_thread.py |
Demonstrates thread management with OpenAI agents, including automatic thread creation for stateless conversations and explicit thread management for maintaining conversation context across multiple interactions. |
openai_responses_client_with_web_search.py |
Shows how to use web search capabilities with OpenAI agents to retrieve and use information from the internet in responses. |
Environment Variables
Make sure to set the following environment variables before running the examples:
OPENAI_API_KEY: Your OpenAI API keyOPENAI_RESPONSES_MODEL_ID: The OpenAI model to use (e.g.,gpt-4o,gpt-4o-mini,gpt-3.5-turbo)