Skip to content

Commit 0622ffc

Browse files
committed
fix(sdk): remove duplicate content property that was overwriting image data
The action object passed to callMainPrompt had two content properties: 1. content: messageContent (conditionally added for images) 2. content: preparedContent (always added) In JS object literals, later properties overwrite earlier ones, so images were never sent to the LLM. The fix removes the duplicate property since preparedContent already handles images correctly via wrapContentForUserMessage -> buildUserMessageContent.
1 parent bcbebe3 commit 0622ffc

File tree

1 file changed

+0
-27
lines changed

1 file changed

+0
-27
lines changed

sdk/src/run.ts

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -299,27 +299,6 @@ type RunExecutionOptions = RunOptions &
299299
fingerprintId: string
300300
}
301301
type RunOnceOptions = Omit<RunExecutionOptions, 'retry' | 'abortController'>
302-
303-
/**
304-
* Build content array from prompt and optional content
305-
*/
306-
function buildMessageContent(
307-
prompt: string,
308-
content?: MessageContent[],
309-
): Array<{ type: 'text'; text: string } | { type: 'image'; image: string; mediaType: string }> {
310-
// If content array is provided, use it (it should already include the text)
311-
if (content && content.length > 0) {
312-
return content.map((item) => {
313-
if (item.type === 'text') {
314-
return { type: 'text' as const, text: item.text }
315-
}
316-
return { type: 'image' as const, image: item.image, mediaType: item.mediaType }
317-
})
318-
}
319-
320-
// Otherwise just return text content from prompt
321-
return [{ type: 'text' as const, text: prompt }]
322-
}
323302
type RunReturnType = RunState
324303

325304
export async function run(options: RunExecutionOptions): Promise<RunState> {
@@ -842,19 +821,13 @@ export async function runOnce({
842821
return getCancelledRunState()
843822
}
844823

845-
// Build content for multimodal messages
846-
const messageContent = buildMessageContent(prompt, content)
847-
const hasImages = messageContent.some((c) => c.type === 'image')
848-
849824
callMainPrompt({
850825
...agentRuntimeImpl,
851826
promptId,
852827
action: {
853828
type: 'prompt',
854829
promptId,
855830
prompt,
856-
// Include content array if it has images, otherwise omit
857-
...(hasImages && { content: messageContent }),
858831
promptParams: params,
859832
content: preparedContent,
860833
fingerprintId: fingerprintId,

0 commit comments

Comments
 (0)