A local plugin for image-heavy chats in Codex, Claude Code and other agents: earlier images stop going out with every message, and the model fetches the one it needs by its ID, also after compaction.
TypeScript ai-agentsclaude-codeclaude-code-plugincodexcodex-plugincontext-managementdeveloper-toolsimage-generationmcpmultimodal
fix(rewrite): 这一轮取回的副本不算“认不出的图”;记下关卡 2、3 的 Codex 结果
chipfighter5c292bb40ebe
diff --git a/docs/v0.8/plan.md b/docs/v0.8/plan.mdindex da7cc49..ea8e770 100644--- a/docs/v0.8/plan.md+++ b/docs/v0.8/plan.md@@ -91,8 +91,11 @@- 文字放在方括号里的 `[…]: #`:Codex 能藏住,Claude 显示出来。- 所以每条记录单独写成一行 `[//]: # (cam …)`,前面空一行;括号里不能有半角括号。好几行连在一起时显示成什么样,在关卡 2 里再看一次。终端版还没看。2. **模型会写**:三个 GPT-6 模型和 Claude Haiku 5.5 都能按说明给新图写特征行、记评价:格式对,编号对,正文里不提;用户在两个桌面版里看不到这些行。+ - Codex(2026-10-19,`local/v08/gate23-codex.ts`,推理强度 low):sol、luna、astra 中英文 6 组全部通过。四轮里,两张上传的图和一张看图工具打开的图都写了特征行;"第一张太暗、第二张构图不错"记到了对的图上;正文没提这些行。最后一轮三张图都成了占位,模型不调用工具,靠特征和评价答对了。sol 在评价那一轮回了一句"记下了",没有透露记录行。+ - 还没验证:Claude;好几行连在一起时,用户在桌面版里是不是也看不到。3. **新图当轮就有编号**:Codex 和 Claude 每一轮发出第一个请求时,看本机记录里有没有这一轮的新图。- 没有时,按出现的顺序推出它们将来的编号。编号只看出现顺序,推出来的应该和之后记录里的一致,要验证。+ - Codex(2026-10-19):通过,6 组都是。新上传的图在它那一轮的第一个请求里就已经在本机记录里(Codex 先写记录再发请求),不用推编号;看图工具打开的图,在紧接着的下一个请求里也认得。Claude 还没验证。4. **压缩之后**:- Codex 用 app-server 的 `thread/compact/start` 压缩,压缩后之前的图还在请求里,以占位的形式出现;- Claude 按 v0.5 的做法补在摘要后面;diff --git a/plugin/src/claude-rewrite.ts b/plugin/src/claude-rewrite.tsindex aff89fe..a1a7e4b 100644--- a/plugin/src/claude-rewrite.ts+++ b/plugin/src/claude-rewrite.ts@@ -97,7 +97,7 @@ export type ClaudeRewriteOptions = {export function rewriteMessages(messages: Json[],- index: Pick<ClaudeIndex, "uploads" | "byKey"> & Partial<Pick<ClaudeIndex, "notes">>,+ index: Pick<ClaudeIndex, "uploads" | "byKey"> & Partial<Pick<ClaudeIndex, "notes" | "copies">>,leaveOut: Set<string>,pixelHash: (image: RequestImage) => string | null,options: ClaudeRewriteOptions = {},@@ -114,7 +114,8 @@ export function rewriteMessages(const drop = refs.filter((ref) => ref.key !== null && !copies.has(ref.key) && leaveOut.has(ref.key) && describe(ref));const sent = refs.filter((ref) => !drop.includes(ref) && !copied.includes(ref));report.sentContentIds = sent.map((ref) => ref.contentId);- const unknown = refs.filter((ref) => !copied.includes(ref) && !describe(ref)).length;+ // A copy the model fetched this turn is known as one, not as an image.+ const unknown = refs.filter((ref) => !copied.includes(ref) && !(ref.key && index.copies?.has(ref.key)) && !describe(ref)).length;if (unknown) report.unknown = unknown;// v0.8: the first image the index knows; the feature line note follows its message.const first = features ? refs.find((ref) => describe(ref)) : undefined;diff --git a/plugin/src/rewrite.ts b/plugin/src/rewrite.tsindex 9fc8102..337e2eb 100644--- a/plugin/src/rewrite.ts+++ b/plugin/src/rewrite.ts@@ -316,7 +316,8 @@ export function rewriteItems(for (const ref of refs) if (unchecked.has(ref.key) && !ref.replaceable) report.locked.push(describe(ref)?.id ?? ref.key);const sent = refs.filter((ref) => !drop.includes(ref) && !copied.includes(ref));report.sentContentIds = sent.map((ref) => ref.contentId);- const unknown = refs.filter((ref) => !copied.includes(ref) && !describe(ref)).length;+ // A copy the model fetched this turn is known as one (the line our fetch tool writes before it), not as an image.+ const unknown = refs.filter((ref) => !copied.includes(ref) && !ref.fetchedId && !describe(ref)).length;if (unknown) report.unknown = unknown;// v0.8: the first image the index knows; the feature line note goes before its turn.const first = features ? refs.find((ref) => describe(ref)) : undefined;