Skip to content

Commit 793d0c5

Browse files
committed
fix: stringify output if it is not a string
1 parent d4f80e1 commit 793d0c5

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

src/agents/mcp_agent.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -805,24 +805,22 @@ export class MCPAgent {
805805
logger.info(`🔄 Attempting structured output with schema: ${outputSchema}`)
806806
logger.info(`🔄 Schema description: ${schemaDescription}`)
807807
logger.info(`🔄 Raw result: ${JSON.stringify(rawResult, null, 2)}`)
808-
808+
809809
// Handle different input formats - rawResult might be an array or object from the agent
810-
let textContent: string = '';
810+
let textContent: string = ''
811811
if (typeof rawResult === 'string') {
812-
textContent = rawResult;
812+
textContent = rawResult
813813
}
814814
else if (rawResult && typeof rawResult === 'object') {
815815
// Handle object format
816-
textContent = JSON.stringify(rawResult);
816+
textContent = JSON.stringify(rawResult)
817817
}
818-
818+
819819
// If we couldn't extract text, use the stringified version
820820
if (!textContent) {
821-
textContent = JSON.stringify(rawResult);
821+
textContent = JSON.stringify(rawResult)
822822
}
823-
824-
825-
823+
826824
// Get detailed schema information for better prompting
827825
const maxRetries = 3
828826
let lastError: string = ''

0 commit comments

Comments
 (0)