Repository navigation
[v2] 接受无新增内容的重复终态 usage 块 - #232
Merged
EricWvi merged 1 commit intoOct 30, 2026
Merged
Conversation
ElephantGit
marked this pull request as ready for review
October 30, 2026 09:35
This was referenced Oct 30, 2026
Collaborator
独立只读审查(成员,非本运行 reviewer)审过 commit 核对点:
一个非阻塞边界:终态块里 |
Merged
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.
OpenRouter 兼容流可能先发送正常文本和 stop,随后在 usage 块里重复一个空的 stop choice,再发送 [DONE]。此前第二个 choice 被一律拒绝,导致已经收齐的答案以 model_response_invalid 失败。
现在仅允许带完整基础 usage 计数、单个 index:0、与既有 stop 相同且没有新增内容的终态元数据 choice。delta 可缺省、null 或为空,role 可缺省、null、空字符串或 assistant。新正文、推理、工具、拒绝、音频、annotations、变化的终态、多 choice、错误 envelope、缺 DONE 和同次收到的 DONE 后数据仍失败;没有 usage 的普通重复空 choice 不会被放行。reasoning_details 在普通 chunk 中仍被忽略且不进入答案;终态元数据中仅缺省/null/空数组可通过。
独立 PR 验证:Go 1.27.1 / Linux,gofmt、go vet ./...、设置真实 PostgreSQL TEST_DATABASE_URL 的 go test -race -count=1 ./...、git diff --check 全部通过。真实 httptest TLS + RemoteProvider 重放脱敏响应:18 字节答案、两个 stop choice、33/37/70 token usage 和 reasoning/cache 明细;回归覆盖空 delta 形式及新增正文、工具、拒绝、推理详情、类型错误、变化终态、缺失 usage 等坏变体。上述自动化回归使用本地 TLS,不需模型密钥。最终 head d6f44d4 的 v2 CI server、frontend、e2e 全部通过。
另完成组合验收:本修复合入集成分支 c52500e 后,在原生 Linux 运行 race 编译的 TestConfiguredProviderServicePostgresRestart(internal/executionruntime/configured_provider_test.go,-test.run=^TestConfiguredProviderServicePostgresRestart$ -test.v -test.timeout=12m),以 V2_REAL_PROVIDER_TEST=1、OpenRouter https://openrouter.ai/api/v1 和 nvidia/nemotron-3-ultra-550b-a55b:free 验证真实模型直连,再通过真实 Node/OpenCode 执行工具并检查 marker;End 后重建 PostgreSQL 连接池与 Service,读回结果一致。组合测试 49.67 秒通过,确认重复终态 usage 不再把完整模型答案误判为失败。此证据包含集成分支的公共 Service、驱动与测试,并非本 PR 单独交付这些组件。
本 PR 严格只有三个交付文件:internal/modelturn/response.go、terminal_usage_test.go、README.md;不新增 Service、Node 驱动或页面。
v2,不涉及 specs。
Refs ora-space/circus#774