Repository navigation
Conversation
…us_response_id LRU)
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.
概述
新增 OpenAI Responses API 兼容端点
POST /v1/responses,将 Responses 协议双向翻译为上游 Anthropic Messages 协议。目标客户端:Codex CLI 等原生走 Responses 协议的调用方。实现
app/responses_compat.py:responses_to_anthropic:instructions→system;input 条目(message/reasoning/function_call/function_call_output,兼容客户端无type的 chat 简写发法)→ Anthropic 消息与块,相邻同角色合并;reasoning.effort映射 minimal/low→low、high→high、xhigh→max(medium 即上游默认档,不带字段);max_output_tokens→max_tokens;tools 仅映射 function 类型anthropic_to_responses:thinking→reasoning(summary_text)、text→message(output_text)、tool_use→function_call;stop_reason=max_tokens→status:"incomplete"ResponsesStreamConverter:Anthropic SSE → Responses SSE(event:+data:帧、sequence_number 递增、无 [DONE] 哨兵、以response.completed收尾)app/response_store.py:previous_response_id内存 LRU(256 条、线程锁、重启清零);首轮 input 同样入库,保证第二轮续接不丢首轮 user 内容POST /v1/responses镜像/v1/chat/completions:鉴权/provider/归一化/reqlog(kind=responses)/调度容灾全套复用,_dispatch与_try_account零改动messages: []发上游测试
tests/unit/test_responses_compat.py、tests/integration/test_gateway_responses.py,Mock 上游,离线可跑)文档
docs/development/04-api-spec.md:新增 §1.4 端点小节(字段映射、effort 映射表、LRU 语义、流式事件序);§1.6 错误表补 previous_response_id 未命中015 / INT-040045;路线图 M2 对应项打勾设计取舍
response_store为进程内存 LRU(与 reqlog 同哲学:续接便利而非持久会话,重启清零,客户端可重发全量 input 兜底)store=true未实现(上游无对应概念),文档已注明