core: boundImages spends its image-budget cut on remote images that carry no payload
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 72/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- typescript
- 领域
- backend
调研方向
从 packages/core/src/session/model-request.ts 开始:mediaBytes(约第 153-154 行)对远程和引用媒体返回 0,boundImages(约第 208-221 行)从 sizes 中选择截断点,但却按文档位置来应用。让移除队列跳过零成本图片,使它们永远不会被替换。在 packages/core 目录下运行 bun run script/test.ts test/session-model-request.test.ts -t "spends the image budget";当只移除一张内联图片且保留两张远程图片时即完成。
由索引模型根据 Issue 内容生成。
描述
Description
boundImages sizes the inline image budget with mediaBytes, which returns 0 for url and ref sources — the comment at packages/core/src/session/model-request.ts:153-154 states that "Remote and provider-referenced media carry no local payload and never count toward the inline budget".
The cut is then chosen by walking sizes in order (:208-214) but applied by document position (:217-221), so zero-cost media occupies slots in the removal queue. When the loop reaches a remote image it subtracts 0 from kept and still advances cut, spending a removal that frees nothing. Remote images are therefore replaced with IMAGE_REMOVED even though deleting them cannot help the budget, and the session loses content that was free to keep.
Steps to reproduce
Two remote images followed by two 13 MiB inline images (26 MiB passes the 25 MiB trigger; one inline image returns it under the 15 MiB target):
expect(removed(boundImages([remote("a.png"), remote("b.png"), inline("c.png"), inline("d.png")]))).toBe(1)
// Expected: 1, Received: 3
cd packages/core && bun run script/test.ts test/session-model-request.test.ts -t "spends the image budget"
Three images are replaced — both remote ones plus one inline — where only the inline one costs anything.
Plugins
none
OpenCode version
dev
Screenshot
No response
- 主要语言
- TypeScript
- 星标
- 224k
- 派生
- 30k
- 平均合并
- 6 小时 51 分钟
- 30 天内合并 PR
- 475
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
anomalyco/opencode 的其他 Issue
-
ACP question tool silently drops questions whose text merely mentions "token"/"secret"/"API key"未关闭
难度 2/5 1-3 小时 新手友好度 62/100
anomalyco/opencode#61283 · 2 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
anomalyco/opencode#61221 · 2 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 65/100
anomalyco/opencode#60584 · 2 条评论 ·
维护者通常 1 天内回复
-
core: OpenRouter BYOK sessions record cost = 0 since v2.2.0 (ignores cost_details.upstream_inference_cost)可能已有人在做 @tneemo 于 4 天前认领。 未关闭reproduced
难度 2/5 1-3 小时 新手友好度 72/100
anomalyco/opencode#60558 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
anomalyco/opencode#60541 · 2 条评论 ·
维护者通常 1 天内回复
查看 anomalyco/opencode 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 84/100
pingdotgg/t3code#30228 · 2 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
-
ci-cd desktop size:low telemetry-improvement telemetry-round-1
难度 2/5 1-3 小时 新手友好度 66/100
vfarcic/dot-agent-deck#2079 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 83/100
维护者通常 1 天内回复