illuma-agents 1.0.53 → 1.0.55
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 +41 -6
- package/dist/cjs/graphs/Graph.cjs.map +1 -1
- package/dist/cjs/llm/bedrock/index.cjs +15 -0
- package/dist/cjs/llm/bedrock/index.cjs.map +1 -1
- package/dist/esm/graphs/Graph.mjs +41 -6
- package/dist/esm/graphs/Graph.mjs.map +1 -1
- package/dist/esm/llm/bedrock/index.mjs +15 -0
- package/dist/esm/llm/bedrock/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/graphs/Graph.ts +44 -6
- package/src/llm/bedrock/index.ts +18 -0
package/package.json
CHANGED
package/src/graphs/Graph.ts
CHANGED
|
@@ -764,30 +764,51 @@ export class StandardGraph extends Graph<t.BaseGraphState, t.GraphNode> {
|
|
|
764
764
|
}
|
|
765
765
|
|
|
766
766
|
// Use withStructuredOutput to bind the schema
|
|
767
|
+
// Always use includeRaw: true internally so we can debug what's returned
|
|
767
768
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
768
769
|
const structuredModel = (model as any).withStructuredOutput(schema, {
|
|
769
770
|
name,
|
|
770
771
|
method,
|
|
771
|
-
includeRaw,
|
|
772
|
+
includeRaw: true, // Always true internally for debugging
|
|
772
773
|
strict: structuredOutputConfig.strict !== false,
|
|
773
774
|
});
|
|
774
775
|
|
|
776
|
+
console.log('[Graph] Structured output config:', {
|
|
777
|
+
name,
|
|
778
|
+
method,
|
|
779
|
+
provider,
|
|
780
|
+
schemaKeys: Object.keys(schema),
|
|
781
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
782
|
+
modelName: (model as any).model || (model as any).modelId || 'unknown',
|
|
783
|
+
});
|
|
784
|
+
|
|
775
785
|
let lastError: Error | undefined;
|
|
776
786
|
let attempts = 0;
|
|
777
787
|
|
|
778
788
|
while (attempts <= maxRetries) {
|
|
779
789
|
try {
|
|
780
790
|
const result = await structuredModel.invoke(finalMessages, config);
|
|
791
|
+
|
|
792
|
+
// Debug: log what we got back
|
|
793
|
+
console.log('[Graph] Structured output raw result type:', typeof result);
|
|
794
|
+
if (result?.raw) {
|
|
795
|
+
const rawMsg = result.raw;
|
|
796
|
+
console.log('[Graph] Raw message content type:', typeof rawMsg?.content);
|
|
797
|
+
console.log('[Graph] Raw message tool_calls:', rawMsg?.tool_calls?.length ?? 0);
|
|
798
|
+
if (rawMsg?.content && typeof rawMsg.content === 'string' && rawMsg.content.length > 0) {
|
|
799
|
+
console.log('[Graph] Raw message text content (first 200):', rawMsg.content.substring(0, 200));
|
|
800
|
+
}
|
|
801
|
+
}
|
|
781
802
|
|
|
782
|
-
// Handle includeRaw
|
|
783
|
-
if (
|
|
803
|
+
// Handle response - we always use includeRaw internally
|
|
804
|
+
if (result?.raw && result?.parsed !== undefined) {
|
|
784
805
|
return {
|
|
785
806
|
structuredResponse: result.parsed as Record<string, unknown>,
|
|
786
807
|
rawMessage: result.raw as AIMessageChunk,
|
|
787
808
|
};
|
|
788
809
|
}
|
|
789
810
|
|
|
790
|
-
//
|
|
811
|
+
// Fallback for models that don't support includeRaw
|
|
791
812
|
return {
|
|
792
813
|
structuredResponse: result as Record<string, unknown>,
|
|
793
814
|
};
|
|
@@ -1189,9 +1210,26 @@ export class StandardGraph extends Graph<t.BaseGraphState, t.GraphNode> {
|
|
|
1189
1210
|
: undefined;
|
|
1190
1211
|
this.cleanupSignalListener();
|
|
1191
1212
|
|
|
1192
|
-
//
|
|
1213
|
+
// CRITICAL: Create a clean message WITHOUT tool_calls for structured output
|
|
1214
|
+
// The rawMessage contains a tool_call for the structured output schema (e.g., "response"),
|
|
1215
|
+
// which would cause the graph router to send it to the tool node, failing with
|
|
1216
|
+
// "Tool 'response' not found". We need to return a clean AI message that ends the graph.
|
|
1217
|
+
let cleanMessage: AIMessageChunk | undefined;
|
|
1218
|
+
if (rawMessage) {
|
|
1219
|
+
// Create a new AIMessageChunk with the structured response as JSON content
|
|
1220
|
+
// but WITHOUT the tool_calls that would trigger tool execution
|
|
1221
|
+
cleanMessage = new AIMessageChunk({
|
|
1222
|
+
content: JSON.stringify(structuredResponse, null, 2),
|
|
1223
|
+
id: rawMessage.id,
|
|
1224
|
+
response_metadata: rawMessage.response_metadata,
|
|
1225
|
+
usage_metadata: rawMessage.usage_metadata,
|
|
1226
|
+
// Explicitly exclude tool_calls to prevent routing to tool node
|
|
1227
|
+
});
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1230
|
+
// Return the clean message (no tool_calls) so the graph ends here
|
|
1193
1231
|
return {
|
|
1194
|
-
messages:
|
|
1232
|
+
messages: cleanMessage ? [cleanMessage] : [],
|
|
1195
1233
|
structuredResponse,
|
|
1196
1234
|
};
|
|
1197
1235
|
} catch (structuredError) {
|
package/src/llm/bedrock/index.ts
CHANGED
|
@@ -101,6 +101,24 @@ export class CustomChatBedrockConverse extends ChatBedrockConverse {
|
|
|
101
101
|
this.promptCache = fields?.promptCache ?? false;
|
|
102
102
|
this.applicationInferenceProfile = fields?.applicationInferenceProfile;
|
|
103
103
|
this.serviceTier = fields?.serviceTier;
|
|
104
|
+
|
|
105
|
+
// Fix: Force supportsToolChoiceValues for Claude models
|
|
106
|
+
// The parent constructor checks `model.includes('claude-3')` but this fails when:
|
|
107
|
+
// 1. Using applicationInferenceProfile ARNs (arn:aws:bedrock:...)
|
|
108
|
+
// 2. Using different naming conventions (claude-4, claude-opus-4, etc.)
|
|
109
|
+
// We need to ensure tool_choice is properly set for withStructuredOutput to work
|
|
110
|
+
const modelName = (fields?.model ?? '').toLowerCase();
|
|
111
|
+
const profileName = (fields?.applicationInferenceProfile ?? '').toLowerCase();
|
|
112
|
+
const isClaudeModel =
|
|
113
|
+
modelName.includes('claude') ||
|
|
114
|
+
modelName.includes('anthropic') ||
|
|
115
|
+
profileName.includes('claude') ||
|
|
116
|
+
profileName.includes('anthropic');
|
|
117
|
+
|
|
118
|
+
if (isClaudeModel && !this.supportsToolChoiceValues?.length) {
|
|
119
|
+
// Claude models support all tool choice values
|
|
120
|
+
this.supportsToolChoiceValues = ['auto', 'any', 'tool'];
|
|
121
|
+
}
|
|
104
122
|
}
|
|
105
123
|
|
|
106
124
|
static lc_name(): string {
|