Skip to content

Commit 17ecb9d

Browse files
authored
fix(agents): preserve image ownership on queued follow-ups (#128272)
1 parent 889d93a commit 17ecb9d

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

‎src/agents/sessions/agent-session-prompting.ts‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -418,11 +418,7 @@ export abstract class AgentSessionPrompting extends AgentSessionBase {
418418
* Internal: Queue a follow-up message (already expanded, no extension command check).
419419
*/
420420
private async queueFollowUp(text: string, images?: ImageContent[]): Promise<void> {
421-
const message = {
422-
role: "user",
423-
content: this.createUserContent(text, images),
424-
timestamp: Date.now(),
425-
} satisfies AgentMessage;
421+
const message = this.createUserMessage(text, images);
426422
this.trackQueuedUserMessage(message, "followUp", text);
427423
this.agent.followUp(message);
428424
}

‎src/agents/sessions/sdk.test.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,9 +480,10 @@ describe("AgentSession queued user turns", () => {
480480
});
481481
});
482482

483-
it("carries prompt facts non-enumerably on the exact steered message", async () => {
483+
it("preserves prompt image ownership across steered and follow-up messages", async () => {
484484
const session = await createSessionFromManager(SessionManager.inMemory());
485485
const steer = vi.spyOn(session.agent, "steer").mockImplementation(() => undefined);
486+
const followUp = vi.spyOn(session.agent, "followUp").mockImplementation(() => undefined);
486487
const media = [{ path: "/tmp/a.png", contentType: "image/png" }];
487488
const imageOrder = ["inline"] as const;
488489
const image: ImageContent = { type: "image", data: "aW1hZ2U=", mimeType: "image/png" };
@@ -509,6 +510,10 @@ describe("AgentSession queued user turns", () => {
509510
mediaImageBlockFactIndexes: [0],
510511
});
511512
expect(JSON.stringify(runtimeMessage)).not.toContain("runtimePromptMediaFacts");
513+
await session.followUp("inspect queued attachment", images);
514+
expect(followUp.mock.calls[0]?.[0]).toMatchObject({
515+
__openclaw: { mediaImageBlockFactIndexes: [0] },
516+
});
512517
});
513518
});
514519

0 commit comments

Comments
 (0)