fix(anthropic): 保持追加图片时的历史编码稳定 - #4549
jiaoyun286 wants to merge 1 commit into
Conversation
按图片自身内容确定编码,移除基于历史位置的降档和图片 413 重试。 请求超限时明确拒绝,统一原生转发、count_tokens 和辅助循环的错误处理。 补充追加、冷缓存、账号切换与准入回归,并同步适配器和结构文档。 Closes lidge-jun#4532
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (53)
💤 Files with no reviewable changes (7)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughAnthropic image handling now normalizes images independently, preserves earlier encoded bytes, enforces image and request-size limits, and returns terminal HTTP 413 errors. The change removes degraded-image retries, updates response routing, adds regression coverage, and documents the policy. ChangesAnthropic stable image admission
Priority: ➖ Normal Estimated code review effort: 4 (Complex) | ~60 minutes Change: Bug fix |
|
✅ Deterministic PR hygiene checks passed. |
✅ READY
Review readiness checklist
✅ 4/4 boxes ticked. This pull request is already Ready for Review. Hygiene✅ Deterministic PR hygiene checks passed. |
리뷰 · 우선순위 73 / 80이 PR은 Anthropic 대화에 스크린샷을 이어 붙일 때, 이미 들어 있던 옛 이미지 바이트가 다시 인코딩되어 프롬프트 프리픽스 캐시가 깨지는 문제를 고칩니다. 이슈 현재 정책 전환의 실무 의미는 분명합니다. “어떻게든 요청을 통과시키려고 히스토리를 재작성”하지 않고, “한도면 호스트가 압축하거나 새 세션을 열어라”로 책임을 옮깁니다. 업스트림 413 뒤 저화질 재시도도 없앱니다. 캐시 안정에는 이득이고, 이미지 많은 긴 스레드는 413을 더 일찍 볼 수 있습니다. 그건 회귀가 아니라 의도된 실패 모드로 문서에 적혀 있어야 하고, 이 PR은 그 문장들을 다국어로 넣고 있습니다. 규모가 큽니다(약 +493/−477, 파일 다수). 문서·structure 동시 수정은 이 정책이 사용자 계약이라서 이해됩니다. 다만 리뷰 부담이 커서, 머지 전에는 normalize/guard 단위 테스트와 e2e 이미지 재시도 테스트가 초록인지만 꼭 보면 됩니다. types/config 분할 캠페인과는 거의 겹치지 않습니다. 중복 이슈 한 줄 요약하면, “추가할수록 과거가 흔들리던” 인코딩을 “각자 자기 크기만”으로 바꾼 올바른 방향입니다. 메인테이너가 확인할 것은 413 거절 UX가 제품적으로 수용 가능한지, 그리고 다국어 문서/structure 노이즈가 이 기능 PR에 같이 들어가도 되는지 정도입니다. 경로 src/adapters/anthropic-image-guard.ts - 요청 한도 초과 시 히스토리 삭제/다운그레이드 대신 413. 의도된 동작인지 제품 확인만 하면 된다. 메인테이너의 판단이 필요한 지점
너의 추천
이 댓글은 grok-bot이 작성했습니다 |
|
Superseded by 44027ae, which carries this work onto Your fix is in that commit, with a What changed on the way in: the carried version had to be reconciled with three other fixes on the same Responses path that landed in the same merge, and the emitted-position store needed one correction. Keying positions by content hash and media type alone collapsed duplicate images in a conversation onto a single ladder slot, which broke age-tier pass-through for histories that repeat an image. Hosted CI caught it, and the merged version gives duplicates their own slots. Issue #4532 is closed against that merge. This pull request is closed as landed, not rejected. |
Summary
Closes #4532.
Appending a screenshot must not change the bytes of images already present in an Anthropic conversation. The previous recency-based tier selection changed historical images at boundaries such as 6 → 7 and 20 → 21 images, invalidating otherwise reusable prompt prefixes.
count_tokens; preserve local admission errors through combination routing and search/media loops without dispatching or failing over a locally rejected request.Intentional tradeoff: this is deterministic encoding plus explicit admission, not session-persisted sticky tiers with later one-way demotion. Aggregate overflow requires compaction or a new session rather than another change to historical image bytes. Stable bytes remove this cache-invalidation cause; they do not guarantee an upstream cache hit.
Verification
bun run typecheck— passed.bun run privacy:scan— passed.bun test tests/lab/core-lab-boundary.test.ts tests/ci-workflows/structure-ssot.test.tscoverage — passed in the focused run; the optional-subsystem boundary remains intact.bun run buildindocs-site— passed, 441 pages.npm packsucceeded. All 1,136 packaged source files matched the working tree, the obsolete retry module was absent, the unpacked package reproduced the same image behavior, and the packaged CLI's--version/--helpworked. The issue author additionally reports successful local packaging validation. No paid Anthropic request or upstream cache-hit measurement was performed.Broader test status — not fully green
bun run test:changed --parallel=1 --dotsran 947 files: 20,297 pass, 39 skip, 23 fail, 1 error. The default parallel attempt had a Bun worker panic, so the completed run used one worker.a84e6e827: 17 provider-management cases whose test hostnames resolve to benchmark-range addresses in this environment, two Linux sandbox fixture checks on macOS, and one service-restart timeout. The baseline comparison ran 184 tests: 164 passed, 20 failed.This PR stays in draft: the broader test run is not fully green, and maintainer/security review is still pending. The tested base is
a84e6e827(four commits behinddevwhen this PR was prepared); the verified patch was not rebased onto untested upstream changes.Checklist
Review readiness checklist
This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:
All CI tests are green on my local testing.
I pushed my PR to the latest dev commit.
I resolved all correct Codex and CodeRabbit findings.
My PR is ready for review.
Summary by CodeRabbit
New Features
count_tokens.Bug Fixes
Documentation