Repository navigation
Conversation
ZCode 活动套餐通道用 HTTP 200 + application/json 返回
`{"code":1005,"msg":"exceed quota limit"}`。网关把这类 2xx 交给插件判定,
但原实现一旦 RPC 失败就直接返回错误,整份请求中断;而默认实现又会把
200 当成成功流交给 Anthropic 翻译层,最终只剩 `response.failed`、
`output` 为空。
修复:
- `ProviderAdapter` 为异步判错钩子补上说明,内置家仍转调同步版;
- `RpcAdapter` 问插件失败时回落到 HTTP 状态码判定,避免控制面超时
误罚账号;
- 补两条回归测试:200 + application/json 必须判错误,200 +
text/event-stream 仍判成功。
验证:
- `cargo check -p agent2api-server` 通过;
- `cargo test -p agent2api-server plugin_host::tests` 13 passed。
注:上游 beta 的 `provider_loop/tests.rs` 与 `api/pipeline.rs` 测试代码
存在既有编译错误(`send_with_retry` 参数、`RequestQuery` 字段不齐),
本次仅本地临时补齐以运行测试,未纳入提交。
Author
|
PR 已就绪:base=beta,mergeable,改动 3 个文件(+101/-7),无冲突。 当前账号 验证: 🤖 本条回复由 AI Agent 生成 |
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.
现象
testwhy0out请求日志里状态码是 200,但响应正文只有:{"type":"error","message":"上游未返回有效 Anthropic 消息"} {"type":"response.failed","response":{"status":"failed","output":[]}}客户端拿到的
output为空,账号也没有进入限流冷却。根因
ZCode 活动套餐通道对超额返回 HTTP 200 +
application/json:{"code":1005,"msg":"exceed quota limit"}网关的
ProviderAdapter::is_error_response默认只按 HTTP 状态码判定,RpcAdapter在控制面 RPC 失败时直接返回错误;成功路径则把 200 当成SSE 交给 Anthropic 翻译层。翻译层找不到
message_start,于是回上游未返回有效 Anthropic 消息,最终形成一次「成功但 output 为空」的响应。修复
RpcAdapter::is_error_response_async在插件 RPC 失败时回落到HTTP 状态码判定,不再让一次控制面超时中断整份请求,也避免误罚账号;
ProviderAdapter的异步钩子补上契约说明,内置家行为不变;200 + application/json必须判为错误;200 + text/event-stream仍判为成功;429仍判为错误。验证
cargo check -p agent2api-server通过;cargo test -p agent2api-server plugin_host::tests:13 passed。上游
beta的provider_loop/tests.rs与api/pipeline.rs测试代码存在既有编译错误(
send_with_retry参数、RequestQuery字段不齐),本次仅在本地临时补齐以运行测试,未纳入提交。
🤖 本条回复由 AI Agent 生成