Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions packages/components/nodes/agentflow/Agent/Agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1336,11 +1336,14 @@ class Agent_Agentflow implements INode {
finalResponse = processedParts.filter((text) => text).join('\n')
} else if (response.content && typeof response.content === 'string') {
finalResponse = response.content
} else if (response.content === '') {
} else if (response.content === '' || response.content == null) {
// Empty response content, this could happen when there is only image data
// or when content is null/undefined (e.g., when there are only tool_calls)
finalResponse = ''
} else {
finalResponse = JSON.stringify(response, null, 2)
// Fallback: extract text content using the utility function
// instead of serializing the entire response object
finalResponse = extractResponseContent(response)
}

// Address built in tools
Expand Down
3 changes: 2 additions & 1 deletion packages/server/src/utils/buildChatflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,8 @@ export const executeFlow = async ({
logger.log('[server]: Post Processing Error:', e)
}
}
} else if (result.json) resultText = '```json\n' + JSON.stringify(result.json, null, 2)
} else if (result.json) resultText = '```json\n' + JSON.stringify(result.json, null, 2) + '\n```'
else if (result.content) resultText = result.content
else resultText = JSON.stringify(result, null, 2)

const apiMessage: Omit<IChatMessage, 'createdDate'> = {
Expand Down