Merge pull request #1813 from GyuminJack/fix/custom-agent-empty-response
fix: resolve empty response when custom agents end with tool calls
This commit is contained in:
commit
c672a2beed
@ -44,8 +44,17 @@ export async function fetchSyncResult(
|
|||||||
return { ok: false, error: `No assistant response found.\n\nSession ID: ${sessionID}` }
|
return { ok: false, error: `No assistant response found.\n\nSession ID: ${sessionID}` }
|
||||||
}
|
}
|
||||||
|
|
||||||
const textParts = lastMessage?.parts?.filter((p) => p.type === "text" || p.type === "reasoning") ?? []
|
// Search assistant messages (newest first) for one with text/reasoning content.
|
||||||
const textContent = textParts.map((p) => p.text ?? "").filter(Boolean).join("\n")
|
// The last assistant message may only contain tool calls with no text.
|
||||||
|
let textContent = ""
|
||||||
|
for (const msg of assistantMessages) {
|
||||||
|
const textParts = msg.parts?.filter((p) => p.type === "text" || p.type === "reasoning") ?? []
|
||||||
|
const content = textParts.map((p) => p.text ?? "").filter(Boolean).join("\n")
|
||||||
|
if (content) {
|
||||||
|
textContent = content
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return { ok: true, textContent }
|
return { ok: true, textContent }
|
||||||
}
|
}
|
||||||
|
|||||||
@ -152,8 +152,15 @@ session_id: ${sessionID}
|
|||||||
return `No assistant response found (task ran in background mode).\n\nSession ID: ${sessionID}`
|
return `No assistant response found (task ran in background mode).\n\nSession ID: ${sessionID}`
|
||||||
}
|
}
|
||||||
|
|
||||||
const textParts = lastMessage?.parts?.filter((p) => p.type === "text" || p.type === "reasoning") ?? []
|
let textContent = ""
|
||||||
const textContent = textParts.map((p) => p.text ?? "").filter(Boolean).join("\n")
|
for (const msg of assistantMessages) {
|
||||||
|
const textParts = msg.parts?.filter((p) => p.type === "text" || p.type === "reasoning") ?? []
|
||||||
|
const content = textParts.map((p) => p.text ?? "").filter(Boolean).join("\n")
|
||||||
|
if (content) {
|
||||||
|
textContent = content
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
const duration = formatDuration(startTime)
|
const duration = formatDuration(startTime)
|
||||||
|
|
||||||
return `SUPERVISED TASK COMPLETED SUCCESSFULLY
|
return `SUPERVISED TASK COMPLETED SUCCESSFULLY
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user