Repository navigation
fix: 400 JSON node 上限单独分类,不再落入通用拒绝(#96) - #97
Merged
Merged
Conversation
generateHttpError 新增 JSON_NODE_LIMIT_REJECTION 分支(位于上下文溢出分支之后):网关的 JSON 节点数上限是结构限制、不是 token 上下文超长,文案中英双语写明上限数值与「压缩上下文无效」,失败码保持 PROVIDER_HTTP_ERROR(不重试、不轮换账号),上游原文仍按既有隐私设计不回显、只引用其给出的上限。 tests/adapter.test.ts 新增回归测试;lib/index.js 已重新构建。 验证:typecheck 干净,npm test 1059/1059,npm run build 成功。
- 文案:压缩上下文「无效」过于绝对。压缩会减少消息条数与 content part 数, 节点数可能因此降到上限以内,改为「压缩上下文通常不足以降到该上限以内」/ "compacting the session usually will not be enough",与 issue 报告人的「通常无效」 一致,避免误导用户放弃可能有效的 /compact。 - 测试:改用 issue #96 的真实响应体形态(error.message 为内层转义 JSON 字符串, 点名上限的句子只存在于 ParsedProviderError.rawMessage),替代此前只覆盖单层 message 的构造,防止 unwrap 路径退化后回归测试仍然全绿。 - JSON_NODE_LIMIT_REJECTION 改为模块内常量(全仓无外部引用)。 - 分支内 test() 与 exec() 合并为一次 exec,nodeLimit 自然收窄为 string。 验证:npm run typecheck 干净;npm test 1059/1059;npm run build 后 lib/ 仅有 index.js 按预期更新;用 issue #96 原始报文回放命中新分支,失败码仍为 PROVIDER_HTTP_ERROR(不重试、不触发压缩、不轮换账号)。
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.
问题 / Problem
Fixes #96.
网关以 400 拒绝
JSON node count cannot exceed 32768时,generateHttpError里没有分支命中它,最终落入通用拒绝:界面只剩有界标识,上游那句点名真正上限的话被丢弃,用户无从下手。The gateway's
JSON node count cannot exceed 32768rejection matched no branch ingenerateHttpErrorand fell through to the generic refusal, which drops the upstream sentence entirely — users got no actionable guidance.改动 / Changes
src/provider-errors.ts:新增JSON_NODE_LIMIT_REJECTION,在上下文溢出分支之后加专用分支。这是结构上限、不是 token 上下文超长:文案中英双语写明上限数值、明确「压缩上下文通常不足以降到该上限以内」,建议新建会话或减少消息与图片;失败码保持PROVIDER_HTTP_ERROR(不重试、不触发压缩、不轮换账号)。上游原文仍按该函数既有的隐私设计不回显,只引用其给出的上限数字——因此未采纳报告人的方案 2(附上游原文)。tests/adapter.test.ts:回归测试(Messages 通道 400,采用 issue 400JSON node count cannot exceed 32768被归到通用拒绝,上游原文被丢弃 #96 的双层转义真实报文,断言失败码、文案含 32768 与双语「通常不足」、且只发 1 次请求)。lib/index.js:已重新构建。A dedicated branch after the context-overflow branch in
generateHttpError: the cap is on the request's JSON structure, not its token length, so the bilingual copy names the stated limit, says compacting usually will not be enough, and advises a new session or fewer messages/images. Failure code staysPROVIDER_HTTP_ERROR.验证 / Verification
npm run typecheck干净 / cleannpm test1059/1059 通过 / passingnpm run build成功 / OK