Repository navigation
feat(provider): 接入 OpenAI 兼容模型服务与工具流式协议 - #60
Merged
Merged
Conversation
新增独立的 OpenAI Chat Completions Provider,实现普通对话、严格 JSON、SSE 流式输出、多工具调用增量聚合、usage 与 finish_reason 校验,以及工具结果的多轮消息映射。 贯通模型注册、系统凭据、诊断、Harness 资格验证、路由预检、CLI、HTTP、OpenAPI 与 Web 控制面;新增稳定且不含响应正文的失败原因分类,并确保未配置 Provider 可以零网络返回诊断结果。 补齐内容隔离、取消与超时分类、404 精确分类、流关闭竞态、端点与超时约束、生成物一致性及 Supervisor 两轮工具循环测试。关联 #47。
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.
背景
解决 #47。
现有工作台已经支持本地模型与 Anthropic-compatible Provider,但 OpenAI Chat Completions 的消息结构、工具调用增量、流式 usage、结束原因和错误协议均有独立语义,不能安全地复用 Anthropic wire adapter。同时,原有诊断结果只能表达较粗的成功或失败,无法稳定区分未配置、认证失败、网络失败、限流、容量不足、模型不存在和协议不兼容。
本 PR 新增独立的 OpenAI 兼容模型接入链路,并继续复用既有 Supervisor、Harness 和工具执行边界;仓库配置不会获得注入端点、请求头或凭据的权限。
主要改动
1. 独立 OpenAI Chat Completions Provider
GET /v1/models与POST /v1/chat/completions。tool_calls,并将每个工具结果展开为独立的role: tool消息。stream_options.include_usage,在收到[DONE]后只输出一个包含完整工具调用与 usage 的最终 chunk。finish_reason、UTF-8、SSE 结束状态、工具参数 JSON、重复或稀疏 index 以及流内模型漂移。2. Registry、凭据与路由集成
openai与独立的openai_compatiblekind。CYBERAGENT_OPENAI_API_KEY、CYBERAGENT_OPENAI_BASE_URL、CYBERAGENT_OPENAI_MODEL。3. 诊断与 Harness 资格结果
not_configured、authentication、network、rate_limit、capacity、model_not_found、protocol_incompatible。not_configured,不再先抛出结构性错误。4. CLI、HTTP、OpenAPI 与 Web 控制面
5. 安全与隐私边界
ChatResponse.Raw,也不会将上游错误正文、prompt、tool arguments、私有 reasoning 字段或原始 SSE delta 写入错误、日志、Activity 或 SQLite。configs/models.yaml仍是说明性示例,不成为运行时端点、请求头或凭据来源。用户与开发者影响
protocol_incompatible,避免截断结果进入 Supervisor。验证
go test:internal/llm、internal/modelregistry、internal/application、internal/httpapi、internal/app、internal/credential、internal/desktop、internal/events全部通过。go vet ./...通过。httptestSSE 的 Supervisor E2E 通过,验证工具调用持久化 ID、独立role: tool回送、单次工具执行以及 Session 只提交一对最终消息。风险与回滚
Closes #47