Repository navigation
Add Agents API support (public beta) - #204
Merged
Merged
Conversation
- Add gpt-6-astra, gpt-6.1-sol, and gpt-5.6-sol model IDs - Add ServiceTier enum with auto, default, flex, priority, and ultrafast tiers - Document Ultrafast usage in the Responses API and README
- New /v1/agents/sessions endpoints: create (with SSE streaming), event stream reopen, client event submission, item listing, and deletion - AgentSessionParameters with agent config, tools (computer use, web search, custom), and environment settings - Lenient beta decoding: documented fields are typed, full payloads kept in a raw member, unknown stream event types decode as .unknown instead of failing the stream - Requests send the OpenAI-Beta: agents=v1 header - Stubs for AIProxy, Azure, and LocalModel services; unit tests and README documentation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds support for the Agents API (public beta), announced at OpenAI DevDay 2026. The Agents API exposes the managed Codex harness: hosted execution, memory, tools, and multi-agent support, with OpenAI handling sessions, orchestration, context compaction and recovery.
Stacked on #203 (GPT-6 models + Ultrafast tier).
New service methods
createAgentSession(_:)—POST /v1/agents/sessionscreateAgentSessionStream(_:)— same endpoint with SSE streamingagentSessionEventStream(sessionID:)—GET /v1/agents/sessions/{id}/events(reopen the stream)submitAgentSessionEvents(sessionID:parameters:)—POST /v1/agents/sessions/{id}/events(follow-up messages, cancellations, approvals)listAgentSessionItems(sessionID:limit:order:after:)—GET /v1/agents/sessions/{id}/itemsdeleteAgentSession(sessionID:)—DELETE /v1/agents/sessions/{id}All requests send the
OpenAI-Beta: agents=v1header.New types
AgentSessionParameters— agent config (model, instructions, tools), environment (openai_hosted/none, desktop), input, stream. Tools:.computerUse(includeScreenshots:),.webSearch, and.customas an escape hatch for shapes not yet modeled (e.g. MCP servers).AgentSessionEventsParameter/AgentSessionClientEvent—.message,.cancel,.custom(approvals).AgentSessionObject,AgentSessionItem,AgentSessionStreamEvent.Beta-resilient decoding
OpenAI has not published the complete Agents API schemas, so response models are deliberately lenient:
raw: OpenAIJSONValuemember..unknown(String)instead of throwing — a decode failure would otherwise terminate the wholeAsyncThrowingStream.submitAgentSessionEventsreturns the raw JSON payload until the response schema is published.AIProxy, Azure, and LocalModel services get
fatalErrorstubs, consistent with how those services handle other unsupported endpoints (e.g. Conversations).Testing
.unknownfallback, and raw-payload retentionswift buildand full test suite pass;swiftformat --lintclean🤖 Generated with Claude Code