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
|
@@ -827,11 +827,11 @@ class StandardGraph extends Graph {
|
|
|
827
827
|
provider: agentContext.provider,
|
|
828
828
|
clientOptions: structuredClientOptions,
|
|
829
829
|
});
|
|
830
|
-
//
|
|
831
|
-
|
|
830
|
+
// For no-tools case, we pass the original messages directly
|
|
831
|
+
// There shouldn't be thinking blocks since this is the first invocation
|
|
832
832
|
const { structuredResponse, rawMessage } = await this.attemptStructuredInvoke({
|
|
833
833
|
currentModel: structuredModel,
|
|
834
|
-
finalMessages
|
|
834
|
+
finalMessages,
|
|
835
835
|
schema,
|
|
836
836
|
structuredOutputConfig: agentContext.structuredOutput,
|
|
837
837
|
provider: agentContext.provider,
|
|
@@ -1078,17 +1078,39 @@ If I seem to be missing something we discussed earlier, just give me a quick rem
|
|
|
1078
1078
|
provider: agentContext.provider,
|
|
1079
1079
|
clientOptions: structuredClientOptions,
|
|
1080
1080
|
});
|
|
1081
|
-
//
|
|
1082
|
-
//
|
|
1083
|
-
//
|
|
1084
|
-
|
|
1081
|
+
// Following LangGraph's Option 2 pattern:
|
|
1082
|
+
// Instead of passing the full conversation (which has thinking blocks),
|
|
1083
|
+
// just pass the model's final response text as a HumanMessage asking for structured output.
|
|
1084
|
+
// This avoids issues with thinking blocks and is more token-efficient.
|
|
1085
|
+
let responseContent = '';
|
|
1085
1086
|
if (resultMessage) {
|
|
1086
|
-
|
|
1087
|
+
if (typeof resultMessage.content === 'string') {
|
|
1088
|
+
responseContent = resultMessage.content;
|
|
1089
|
+
}
|
|
1090
|
+
else if (Array.isArray(resultMessage.content)) {
|
|
1091
|
+
// Extract text parts only (skip thinking blocks, tool_use, etc.)
|
|
1092
|
+
responseContent = resultMessage.content
|
|
1093
|
+
.filter((c) => typeof c === 'object' && c !== null &&
|
|
1094
|
+
c.type === 'text' &&
|
|
1095
|
+
typeof c.text === 'string')
|
|
1096
|
+
.map(c => c.text)
|
|
1097
|
+
.join('\n');
|
|
1098
|
+
}
|
|
1087
1099
|
}
|
|
1088
|
-
|
|
1100
|
+
if (!responseContent) {
|
|
1101
|
+
console.log('[Graph] No response content to structure, skipping');
|
|
1102
|
+
throw new Error('No response content available for structured output');
|
|
1103
|
+
}
|
|
1104
|
+
console.log('[Graph] Structuring response content (first 200 chars):', responseContent.substring(0, 200));
|
|
1105
|
+
// Create a simple message asking to structure the response
|
|
1106
|
+
const structuredMessages = [
|
|
1107
|
+
new messages.HumanMessage({
|
|
1108
|
+
content: `Based on the following response, extract and return the data in the required structured format:\n\n${responseContent}`,
|
|
1109
|
+
}),
|
|
1110
|
+
];
|
|
1089
1111
|
const { structuredResponse, rawMessage } = await this.attemptStructuredInvoke({
|
|
1090
1112
|
currentModel: structuredModel,
|
|
1091
|
-
finalMessages:
|
|
1113
|
+
finalMessages: structuredMessages,
|
|
1092
1114
|
schema,
|
|
1093
1115
|
structuredOutputConfig: agentContext.structuredOutput,
|
|
1094
1116
|
provider: agentContext.provider,
|