Repository navigation
fix(providers): 被拒的请求去掉所有附件重发,ImageFallback 改名 AttachmentFallback - #423
Merged
Merged
Conversation
This was referenced Nov 19, 2026
- image-fallback.ts 改名 attachment-fallback.ts;imageLeftOut、withoutImages、 handlesRefusedImages 跟着改成 attachment 的叫法。 - 下一个提交让它管请求带上的所有附件,名字先改,免得行为和名字对不上。 - 市场上的第三方 provider 包都没有用到这几个名字。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Phantivia
force-pushed
the
fix/attachment-fallback
branch
from
November 19, 2026 04:39
3a1b0d3 to
6c894df
Compare
- 根因:AttachmentFallback 只把图片算作请求带上的附件,请求因为一份 PDF 或一段录音被拒时 去完图片仍然超,最后 413 走交接或 400 直接失败。 - 新增 accepts 选项:client 会发的附件类型,不给只算图片(框架内建的 client 只发图片)。 ProviderRegistry.bind 套的那层取模块的 accepts,和 Core 判断模型收哪些类型用的是同一个函数。 - 说明行 attachmentLeftOut 改说「这份附件」;日志字段 images 改 attachments。 - 测试:模块收的非图片附件被拒后去掉重发、之后不再带;模块不收的类型 client 没发过,不重发。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Phantivia
force-pushed
the
fix/attachment-fallback
branch
from
November 19, 2026 04:52
6c894df to
a33db35
Compare
This was referenced Nov 19, 2026
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.


带附件的请求被上游以 413 拒收,或以 400 拒收且不是上下文超限时,回落层现在去掉这次请求带上的所有附件重发一次,不再只去图片。
为什么
回落层只把图片算作请求带上的附件。Coopanion 的 Gemini 端点从 v0.2.21 起还发音频、视频、PDF 和纯文本;请求因为一份 PDF 或一段录音被拒时,去完图片仍然超,最后 413 走交接或 400 直接失败。Coopanion 为此在 Gemini 那条路上另加了一套「发送前 18 MiB 额度」,那套额度又引出了 Pal-AI-Lab/Coopanion#741 的问题(旧 PDF 占满额度、新截图只剩文字行)。回落层管所有附件之后,Coopanion 那边可以删掉这套预筛,和其他协议一样被拒再去附件。
两个提交(请用 rebase 合并,保留两步)
refactor(providers):ImageFallback→AttachmentFallback(image-fallback.ts→attachment-fallback.ts),imageLeftOut→attachmentLeftOut,withoutImages→withoutAttachments,handlesRefusedImages→handlesRefusedAttachments。行为不变。fix(providers):新增accepts选项(client 会发的附件类型,不给只算图片);ProviderRegistry.bind套的那层取模块的accepts,和 Core 判断模型收哪些类型用同一个函数。说明行改说「这份附件」。兼容
accepts,行为和以前一样。检查
pnpm test:292 个文件、5227 条通过,4 条跳过(rebase 到 9609ddc 之后又跑了tests/providers和tests/core:623 条通过)。pnpm run typecheck通过。drops an attachment of another type the module accepts…在改动前失败、改动后通过;does not retry for an attachment type the module does not accept…挡住把没发出去的附件也算进去。没验证的
Gemini 因为请求体超限拒收时回 413 还是 400,没有用真服务验过;两种都会触发重发,只要 400 不被模块的
contextOverflow认作上下文超限。🤖 Generated with Claude Code