Skip to content

fix: include error code in Responses failure events#21

Open
AmPlace wants to merge 1 commit into
HM2899:mainfrom
AmPlace:agent/fix-responses-failed-error-code
Open

fix: include error code in Responses failure events#21
AmPlace wants to merge 1 commit into
HM2899:mainfrom
AmPlace:agent/fix-responses-failed-error-code

Conversation

@AmPlace

@AmPlace AmPlace commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

变更说明

Responses 协议的两条失败事件构造路径目前只会写入 typemessage

  • Failure(...)
  • LiveStreamer.Fail(...)

部分 Responses 客户端会读取 response.failed.response.error.code。字段缺失时,客户端无法按正常的 Responses 错误结构处理失败事件。

这个 PR 在两条路径里补上 code,值与已经规范化后的 errorType 保持一致;没有传入错误类型时,继续使用现有的 server_error 默认值。

修改只影响 response.failed 的错误对象,不改变事件顺序、结束帧或其他流式行为。

测试

新增断言覆盖普通失败序列和已经启动后的流式失败路径:

go test ./internal/protocol/responses ./internal/server

结果:

ok github.com/hm2899/grokcli-2api/internal/protocol/responses
ok github.com/hm2899/grokcli-2api/internal/server

另外运行了:

git diff --check

未发现补丁格式问题。

@AmPlace
AmPlace marked this pull request as ready for review July 23, 2026 10:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant