Skip to content

feat(model/openai): add Responses API ChatModel - #1002

Open
jesse-engineer wants to merge 2 commits into
cloudwego:mainfrom
jesse-engineer:feat/openai-responses-chatmodel
Open

jesse-engineer wants to merge 2 commits into
cloudwego:mainfrom
jesse-engineer:feat/openai-responses-chatmodel

Conversation

@jesse-engineer

@jesse-engineer jesse-engineer commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

What type of PR is this?

feat

Check the PR title.

  • This PR title matches the conventional commit format.
  • The description is user-oriented and clear.
  • Separate user-documentation PR (English/Chinese README documentation and a runnable example are included here).

Detailed description

Applications using schema.Message and ToolCallingChatModel currently need a custom adapter to call /v1/responses. This adds NewResponsesChatModel and ResponsesChatModelConfig to components/model/openai, so these applications can use Responses with their existing message history and middleware. NewChatModel continues to use Chat Completions.

The new adapter supports generation and streaming, text/image inputs, custom function calls and tool choice, Eino callbacks, response/request IDs, token usage, and optional stored-response continuation. Encrypted reasoning items are retained in Message.Extra and restored after session serialization. Failed/cancelled responses and truncated streams return errors; refusals and output limits retain meaningful finish reasons. SDK retries are disabled for application/ADK retry ownership.

An optional StreamEventHandler lets applications classify gateway-specific SSE events using their own error types. Immediate errors stop and close the stream; incomplete-stream errors apply only when no terminal response arrives. Standard terminal responses and SDK/transport errors retain precedence, and fallback state is isolated per stream. No gateway-specific event handling is built into the component.

agenticopenai remains the provider-native AgenticMessage implementation. This proposal addresses the classic-message compatibility use case discussed in #758 and #782; it does not expose hosted tools or arbitrary native content blocks.

Compatibility: the official SDK dependency is github.com/openai/openai-go/v3 v3.35.0, matching the version currently used by agenticopenai on main. This raises this module's minimum Go version from 1.18 to 1.22. The Eino dependency remains v0.7.13.

Validation

  • Go 1.25.6: component tests, new example compilation, and go test -race -gcflags="all=-N -l" . pass.
  • Go 1.22.12: component tests and example compilation pass (external linking used for the local macOS linker).
  • 25 Responses tests cover request options, tool continuation, encrypted-reasoning JSON round trips, streaming, usage, errors, refusals, and response-ID continuation.
  • Component statement coverage: 75.5%.
  • golangci-lint (govet, ineffassign, unused): 0 issues; goimports and git whitespace checks pass.
  • Stream-event tests cover error identity, immediate connection closure, successful responses with quota notices, native error precedence, and concurrent stream isolation.
  • A downstream integration check using the consumer’s real ADK retry/failover policies passed 9 scenarios, including retry exhaustion followed by successful failover for both quota and upstream errors.
  • Tests use local HTTP fixtures and require no API credentials.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant