illuma-agents 1.0.63 → 1.0.65
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/graphs/Graph.cjs +32 -10
- package/dist/cjs/graphs/Graph.cjs.map +1 -1
- package/dist/esm/graphs/Graph.mjs +33 -11
- package/dist/esm/graphs/Graph.mjs.map +1 -1
- package/package.json +1 -1
- package/src/graphs/Graph.ts +36 -11
package/src/graphs/Graph.ts
CHANGED
|
@@ -41,7 +41,6 @@ import {
|
|
|
41
41
|
} from '@/common';
|
|
42
42
|
import {
|
|
43
43
|
formatAnthropicArtifactContent,
|
|
44
|
-
stripThinkingBlocksFromMessages,
|
|
45
44
|
ensureThinkingBlockInMessages,
|
|
46
45
|
convertMessagesToContent,
|
|
47
46
|
addBedrockCacheControl,
|
|
@@ -1207,14 +1206,14 @@ export class StandardGraph extends Graph<t.BaseGraphState, t.GraphNode> {
|
|
|
1207
1206
|
clientOptions: structuredClientOptions,
|
|
1208
1207
|
});
|
|
1209
1208
|
|
|
1210
|
-
//
|
|
1211
|
-
|
|
1209
|
+
// For no-tools case, we pass the original messages directly
|
|
1210
|
+
// There shouldn't be thinking blocks since this is the first invocation
|
|
1212
1211
|
|
|
1213
1212
|
const { structuredResponse, rawMessage } =
|
|
1214
1213
|
await this.attemptStructuredInvoke(
|
|
1215
1214
|
{
|
|
1216
1215
|
currentModel: structuredModel,
|
|
1217
|
-
finalMessages
|
|
1216
|
+
finalMessages,
|
|
1218
1217
|
schema,
|
|
1219
1218
|
structuredOutputConfig: agentContext.structuredOutput!,
|
|
1220
1219
|
provider: agentContext.provider,
|
|
@@ -1534,20 +1533,46 @@ If I seem to be missing something we discussed earlier, just give me a quick rem
|
|
|
1534
1533
|
clientOptions: structuredClientOptions,
|
|
1535
1534
|
});
|
|
1536
1535
|
|
|
1537
|
-
//
|
|
1538
|
-
//
|
|
1539
|
-
//
|
|
1540
|
-
|
|
1536
|
+
// Following LangGraph's Option 2 pattern:
|
|
1537
|
+
// Instead of passing the full conversation (which has thinking blocks),
|
|
1538
|
+
// just pass the model's final response text as a HumanMessage asking for structured output.
|
|
1539
|
+
// This avoids issues with thinking blocks and is more token-efficient.
|
|
1540
|
+
let responseContent = '';
|
|
1541
1541
|
if (resultMessage) {
|
|
1542
|
-
|
|
1542
|
+
if (typeof resultMessage.content === 'string') {
|
|
1543
|
+
responseContent = resultMessage.content;
|
|
1544
|
+
} else if (Array.isArray(resultMessage.content)) {
|
|
1545
|
+
// Extract text parts only (skip thinking blocks, tool_use, etc.)
|
|
1546
|
+
responseContent = resultMessage.content
|
|
1547
|
+
.filter((c): c is { type: string; text: string } =>
|
|
1548
|
+
typeof c === 'object' && c !== null &&
|
|
1549
|
+
(c as { type?: string }).type === 'text' &&
|
|
1550
|
+
typeof (c as { text?: string }).text === 'string'
|
|
1551
|
+
)
|
|
1552
|
+
.map(c => c.text)
|
|
1553
|
+
.join('\n');
|
|
1554
|
+
}
|
|
1555
|
+
}
|
|
1556
|
+
|
|
1557
|
+
if (!responseContent) {
|
|
1558
|
+
console.log('[Graph] No response content to structure, skipping');
|
|
1559
|
+
throw new Error('No response content available for structured output');
|
|
1543
1560
|
}
|
|
1544
|
-
|
|
1561
|
+
|
|
1562
|
+
console.log('[Graph] Structuring response content (first 200 chars):', responseContent.substring(0, 200));
|
|
1563
|
+
|
|
1564
|
+
// Create a simple message asking to structure the response
|
|
1565
|
+
const structuredMessages: BaseMessage[] = [
|
|
1566
|
+
new HumanMessage({
|
|
1567
|
+
content: `Based on the following response, extract and return the data in the required structured format:\n\n${responseContent}`,
|
|
1568
|
+
}),
|
|
1569
|
+
];
|
|
1545
1570
|
|
|
1546
1571
|
const { structuredResponse, rawMessage } =
|
|
1547
1572
|
await this.attemptStructuredInvoke(
|
|
1548
1573
|
{
|
|
1549
1574
|
currentModel: structuredModel,
|
|
1550
|
-
finalMessages:
|
|
1575
|
+
finalMessages: structuredMessages,
|
|
1551
1576
|
schema,
|
|
1552
1577
|
structuredOutputConfig: agentContext.structuredOutput!,
|
|
1553
1578
|
provider: agentContext.provider,
|