fix: persist history image injections
This commit is contained in:
@@ -13,6 +13,7 @@ Docs: https://docs.clawd.bot
|
|||||||
- CLI: move gateway service commands under `clawdbot gateway` and add `gateway probe` for reachability.
|
- CLI: move gateway service commands under `clawdbot gateway` and add `gateway probe` for reachability.
|
||||||
|
|
||||||
### Fixes
|
### Fixes
|
||||||
|
- Embedded runner: persist injected history images so attachments aren’t reloaded each turn. (#1374) Thanks @Nicell.
|
||||||
- Nodes tool: include agent/node/gateway context in tool failure logs to speed approval debugging.
|
- Nodes tool: include agent/node/gateway context in tool failure logs to speed approval debugging.
|
||||||
- macOS: exec approvals now respect wildcard agent allowlists (`*`).
|
- macOS: exec approvals now respect wildcard agent allowlists (`*`).
|
||||||
- macOS: allow SSH agent auth when no identity file is set. (#1384) Thanks @ameno-.
|
- macOS: allow SSH agent auth when no identity file is set. (#1384) Thanks @ameno-.
|
||||||
|
|||||||
@@ -627,6 +627,7 @@ export async function runEmbeddedAttempt(
|
|||||||
// Inject history images into their original message positions.
|
// Inject history images into their original message positions.
|
||||||
// This ensures the model sees images in context (e.g., "compare to the first image").
|
// This ensures the model sees images in context (e.g., "compare to the first image").
|
||||||
if (imageResult.historyImagesByIndex.size > 0) {
|
if (imageResult.historyImagesByIndex.size > 0) {
|
||||||
|
let didMutate = false;
|
||||||
for (const [msgIndex, images] of imageResult.historyImagesByIndex) {
|
for (const [msgIndex, images] of imageResult.historyImagesByIndex) {
|
||||||
// Bounds check: ensure index is valid before accessing
|
// Bounds check: ensure index is valid before accessing
|
||||||
if (msgIndex < 0 || msgIndex >= activeSession.messages.length) continue;
|
if (msgIndex < 0 || msgIndex >= activeSession.messages.length) continue;
|
||||||
@@ -635,6 +636,7 @@ export async function runEmbeddedAttempt(
|
|||||||
// Convert string content to array format if needed
|
// Convert string content to array format if needed
|
||||||
if (typeof msg.content === "string") {
|
if (typeof msg.content === "string") {
|
||||||
msg.content = [{ type: "text", text: msg.content }];
|
msg.content = [{ type: "text", text: msg.content }];
|
||||||
|
didMutate = true;
|
||||||
}
|
}
|
||||||
if (Array.isArray(msg.content)) {
|
if (Array.isArray(msg.content)) {
|
||||||
// Check for existing image content to avoid duplicates across turns
|
// Check for existing image content to avoid duplicates across turns
|
||||||
@@ -653,11 +655,16 @@ export async function runEmbeddedAttempt(
|
|||||||
// Only add if this image isn't already in the message
|
// Only add if this image isn't already in the message
|
||||||
if (!existingImageData.has(img.data)) {
|
if (!existingImageData.has(img.data)) {
|
||||||
msg.content.push(img);
|
msg.content.push(img);
|
||||||
|
didMutate = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (didMutate) {
|
||||||
|
// Persist message mutations (e.g., injected history images) so we don't re-scan/reload.
|
||||||
|
activeSession.agent.replaceMessages(activeSession.messages);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cacheTrace?.recordStage("prompt:images", {
|
cacheTrace?.recordStage("prompt:images", {
|
||||||
|
|||||||
Reference in New Issue
Block a user