Skip to content

Stop paying the multimodal tax. Your AI agent keeps every image it has seen but only sends the ones it needs: lighter chats, no endless reconnecting, no starting over. Works with Codex, Claude Code, Cline, Gemini CLI, OpenCode, WorkBuddy and more. Install once, forget it.

fix(children): exclude composer predictions from side chat counts

lin-coco10220ccbfd6c
diff --git a/plugin/src/children.ts b/plugin/src/children.ts
index c75ecc1..b7d41ad 100644
--- a/plugin/src/children.ts
+++ b/plugin/src/children.ts
@@ -36,7 +36,10 @@ export function recordChild(taskId: string, childId: string, child: Child, dir =
// The task a request's thread belongs to as a side chat or as a subagent started without history, or null. A
// subagent's first request can come before Codex writes its rollout; it is found at the next one.
-export function childOf(identity: { threadId: string | null; forkedFrom: string | null }, sessionsDir: string, at: string): { task: string; id: string; child: Child } | null {
+export function childOf(identity: { threadId: string | null; forkedFrom: string | null; turnTrigger?: string | null }, sessionsDir: string, at: string): { task: string; id: string; child: Child } | null {
+ // Codex also forks an ephemeral thread for its suggested next message. Keep rewriting those requests, but do not
+ // present an app-generated composer prediction as a side chat the user opened (HTTP and WebSocket share this path).
+ if (identity.turnTrigger === "composer_predictions") return null;
const id = identity.threadId;
if (!id) return null;
const origin = sideChatOrigin(id, identity.forkedFrom, sessionsDir);
diff --git a/plugin/src/proxy.ts b/plugin/src/proxy.ts
index 86675d2..0f2e8a9 100644
--- a/plugin/src/proxy.ts
+++ b/plugin/src/proxy.ts
@@ -127,7 +127,7 @@ export function forwardHeaders(headers: IncomingHttpHeaders, upstream = UPSTREAM
// Which task a request belongs to, from Codex's own turn metadata header.
// v0.7: and where that task came from: a side chat (a fork Codex keeps in memory only) names the task it was forked
// from, a subagent its parent (also in Codex's own header).
-export type RequestIdentity = { threadId: string | null; turnId: string | null; windowId: string | null; forkedFrom: string | null; parentThreadId: string | null; subagentKind: string | null };
+export type RequestIdentity = { threadId: string | null; turnId: string | null; windowId: string | null; forkedFrom: string | null; parentThreadId: string | null; subagentKind: string | null; turnTrigger: string | null };
export function requestIdentity(headers: IncomingHttpHeaders): RequestIdentity {
let meta: Json = {};
try { meta = JSON.parse(String(headers["x-codex-turn-metadata"] ?? "{}")); } catch { /* not JSON */ }
@@ -135,6 +135,7 @@ export function requestIdentity(headers: IncomingHttpHeaders): RequestIdentity {
return {
threadId: meta.thread_id ?? meta.session_id ?? null, turnId: meta.turn_id ?? null, windowId: header("x-codex-window-id"),
forkedFrom: meta.forked_from_thread_id ?? null, parentThreadId: meta.parent_thread_id ?? header("x-codex-parent-thread-id"), subagentKind: meta.subagent_kind ?? null,
+ turnTrigger: meta.turn_trigger ?? null,
};
}
diff --git a/spike/src/children.test.ts b/spike/src/children.test.ts
index 5e581bc..a866acd 100644
--- a/spike/src/children.test.ts
+++ b/spike/src/children.test.ts
@@ -59,3 +59,13 @@ test("each child is recorded once under its task; later requests leave the recor
assert.equal(recordChild("../escape", SIDE, { kind: "side", from: MAIN, at: "x" }, dir), false);
assert.deepEqual(readChildren("../escape", dir), {});
});
+
+// Composer suggestions are app-generated ephemeral forks, not user-created side chats.
+test("composer predictions are not registered as side chats", () => {
+ const { sessionsDir } = sessions();
+ const at = "2026-10-15T10:00:00Z";
+ const identity = { threadId: SIDE, forkedFrom: MAIN, turnTrigger: "composer_predictions" };
+ assert.equal(childOf(identity, sessionsDir, at), null);
+ assert.equal(childOf({ ...identity, turnTrigger: "user" }, sessionsDir, at)?.child.kind, "side");
+ assert.equal(childOf({ threadId: SIDE, forkedFrom: MAIN }, sessionsDir, at)?.child.kind, "side", "older metadata remains compatible");
+});
diff --git a/spike/src/proxy.test.ts b/spike/src/proxy.test.ts
index 5eb4998..ba501f8 100644
--- a/spike/src/proxy.test.ts
+++ b/spike/src/proxy.test.ts
@@ -41,16 +41,16 @@ test("NO_PROXY entries covering the upstream host mean a direct connection", ()
test("the task a request belongs to is read from x-codex-turn-metadata", () => {
const headers = { "x-codex-turn-metadata": JSON.stringify({ thread_id: "thread-a", turn_id: "turn-1" }), "x-codex-window-id": "thread-a:0" };
- assert.deepEqual(requestIdentity(headers), { threadId: "thread-a", turnId: "turn-1", windowId: "thread-a:0", forkedFrom: null, parentThreadId: null, subagentKind: null });
- assert.deepEqual(requestIdentity({ "x-codex-turn-metadata": "not json" }), { threadId: null, turnId: null, windowId: null, forkedFrom: null, parentThreadId: null, subagentKind: null });
+ assert.deepEqual(requestIdentity(headers), { threadId: "thread-a", turnId: "turn-1", windowId: "thread-a:0", forkedFrom: null, parentThreadId: null, subagentKind: null, turnTrigger: null });
+ assert.deepEqual(requestIdentity({ "x-codex-turn-metadata": "not json" }), { threadId: null, turnId: null, windowId: null, forkedFrom: null, parentThreadId: null, subagentKind: null, turnTrigger: null });
});
// v0.7: as Codex 0.162 sends them (docs/v0.7/plan.md §3).
test("a side chat's requests name the task it was forked from, a subagent's its parent", () => {
const side = { "x-codex-turn-metadata": JSON.stringify({ thread_id: "side", session_id: "side", turn_id: "turn-s", forked_from_thread_id: "main" }) };
- assert.deepEqual(requestIdentity(side), { threadId: "side", turnId: "turn-s", windowId: null, forkedFrom: "main", parentThreadId: null, subagentKind: null });
+ assert.deepEqual(requestIdentity(side), { threadId: "side", turnId: "turn-s", windowId: null, forkedFrom: "main", parentThreadId: null, subagentKind: null, turnTrigger: null });
const child = { "x-codex-turn-metadata": JSON.stringify({ thread_id: "child", session_id: "main", turn_id: "turn-c", parent_thread_id: "main", subagent_kind: "thread_spawn" }), "x-codex-parent-thread-id": "main", "x-openai-subagent": "collab_spawn" };
- assert.deepEqual(requestIdentity(child), { threadId: "child", turnId: "turn-c", windowId: null, forkedFrom: null, parentThreadId: "main", subagentKind: "thread_spawn" });
+ assert.deepEqual(requestIdentity(child), { threadId: "child", turnId: "turn-c", windowId: null, forkedFrom: null, parentThreadId: "main", subagentKind: "thread_spawn", turnTrigger: null });
// Codex's own header, when the metadata does not say.
assert.equal(requestIdentity({ "x-codex-turn-metadata": JSON.stringify({ thread_id: "child" }), "x-codex-parent-thread-id": "main" }).parentThreadId, "main");
});
@@ -443,3 +443,15 @@ test("a side chat's request is rewritten with the images of the task it came fro
// A thread with a rollout of its own is no side chat, whatever its requests say (a fork the user made).
assert.equal(needsRewrite(threadId, selections, sessions, "01a0d307-0000-7000-8000-0000000000b9"), true);
});
+
+// Only child-list classification changes: prediction requests still retain their attachment-management context.
+test("composer predictions retain their trigger and inherited image rewriting", () => {
+ const { threadId, sessions, selections, body } = fixture();
+ const identity = requestIdentity({ "x-codex-turn-metadata": JSON.stringify({ thread_id: "prediction", forked_from_thread_id: threadId, turn_trigger: "composer_predictions" }) });
+ assert.equal(identity.turnTrigger, "composer_predictions");
+ assert.equal(identity.forkedFrom, threadId);
+ assert.equal(needsRewrite(identity.threadId, selections, sessions, identity.forkedFrom), true);
+ const result = rewriteBody(body(), "zstd", identity.threadId!, sessions, selections, null, identity.forkedFrom);
+ assert.equal(result.report.auto, true);
+ assert.equal(result.report.replaced.length, 2);
+});