Conversation
8 tasks
…type The core sdk package imported internal/utils for the request-header context key, which pulled the AWS SDK (74 aws-sdk-go-v2/smithy-go packages) into every consumer. Move the context key and merge logic into a dependency-free internal/reqheaders package; internal/utils keeps thin wrappers so provider call sites are unchanged. Custom headers were applied after the default JSON Content-Type, so a provider or context Content-Type relabelled a JSON body. BuildRequest and the OpenAI speech request now set it last, matching the multipart paths and the documented "transport headers are applied last" contract. The header tests now assert the content type on JSON requests, not only multipart ones. Document that context headers reach every provider called with the context, so credentials belong in provider options.
Verified against the live service on 2026-09-20 across all catalog models: - Several Completions models (GLM, DeepSeek, LongCat) accept the developer role but silently ignore its content. Developer messages are now sent as system messages, which every model honors. - Some Completions routes reject a replayed assistant tool call that carries no reasoning_content. It is now always sent, empty when the history has none; every route accepts the empty value. Both rules apply to every Completions route and come from the service's observed behavior. Nothing is inferred from the model name: the same model family is served by different upstreams with different behavior. Also build the protocol delegates once in New instead of per call, omit the Authorization header when no key is configured, carry catalog display names on returned models, and add deepseek-flash, which the endpoint table omits but the live service lists and serves. Tests: an offline test routes every catalog model to its endpoint, and env-gated TestIntegration_* tests (OPENCODE_GO_API_KEY) exercise a streamed tool loop, a replay without reasoning and a developer instruction on every catalog model.
akazwz
force-pushed
the
feat/provider-headers
branch
from
September 21, 2026 07:53
8069048 to
0c1c2e5
Compare
OpenCode Go added Grok 4.7 to its endpoint table on 2026-09-21; it is served from /responses like Grok 4.6.
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.
改动说明
新增 provider 级
WithHeaders和调用级sdk.WithRequestHeaders,支持应用配置网关请求头,并在共享 provider 时通过 context 为每个会话传递独立的 session ID。配置时复制请求头,按“默认值 → provider 配置 → context 配置”的顺序合并,同名请求头忽略大小写。相关聊天 provider 和 OpenAI 媒体 provider 的模型发现、探测、生成、流式调用及文件上传均接入统一请求头配置,同时保留正确的 AWS 签名顺序和 multipart boundary。
新增
provider/opencode/go(包名opencodego),内置 28 个模型的明确协议映射,复用现有 Completions、Responses 和 Anthropic Messages 实现。支持实时模型发现、自定义协议映射和实际生成探测;未注册协议的模型在发送生成请求前返回错误。会话请求头通过 context 保留到工具续轮,不修改共享 provider 的会话状态。同步更新 README、provider 文档、API 参考和 skill 参考,补充配置示例,并说明端点可达性检查与认证及生成探测的区别。
验证结果
go build ./...、go vet ./...和go test ./... -short -count=1 -race均通过。golangci-lint run ./...通过,0 个问题。provider.go、provider_test.go后,重新运行对应 provider 测试通过;git diff --check通过。验证范围与限制
真实 E2E 使用三种协议的代表模型,未逐个覆盖目录中的全部模型,也未验证所有 provider 的真实账号。
一次模型回答违反了经独立检查确认的优化约束,但输入已完整传递,SDK 数据传输和 reasoning 回传检查通过。SDK 链路验证通过不代表模型答案始终正确。
真实测试脚本和凭证未包含在本次提交中。