@illuma-ai/agents 1.1.22 → 1.1.23
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.map +1 -1
- package/dist/cjs/graphs/MultiAgentGraph.cjs +20 -0
- package/dist/cjs/graphs/MultiAgentGraph.cjs.map +1 -1
- package/dist/cjs/utils/llm.cjs.map +1 -1
- package/dist/esm/graphs/Graph.mjs.map +1 -1
- package/dist/esm/graphs/MultiAgentGraph.mjs +20 -0
- package/dist/esm/graphs/MultiAgentGraph.mjs.map +1 -1
- package/dist/esm/utils/llm.mjs.map +1 -1
- package/package.json +1 -1
- package/src/graphs/Graph.ts +1 -0
- package/src/graphs/MultiAgentGraph.ts +23 -0
- package/src/graphs/__tests__/multi-agent-delegate.test.ts +41 -27
- package/src/utils/llm.ts +1 -0
|
@@ -764,6 +764,26 @@ class MultiAgentGraph extends StandardGraph {
|
|
|
764
764
|
}));
|
|
765
765
|
}
|
|
766
766
|
}
|
|
767
|
+
/**
|
|
768
|
+
* Ensure messages end with a HumanMessage.
|
|
769
|
+
* After stripping tool artifacts, the last message may be an AIMessage
|
|
770
|
+
* (orchestrator's reasoning before the handoff). Some providers (Bedrock,
|
|
771
|
+
* Google/VertexAI) reject conversations ending with an assistant message.
|
|
772
|
+
* Convert the trailing AIMessage to a HumanMessage to preserve any useful
|
|
773
|
+
* context (e.g., compacted tool summaries) while satisfying the API requirement.
|
|
774
|
+
*/
|
|
775
|
+
if (cleaned.length > 0 && cleaned[cleaned.length - 1].getType() === 'ai') {
|
|
776
|
+
const lastAI = cleaned[cleaned.length - 1];
|
|
777
|
+
const content = typeof lastAI.content === 'string'
|
|
778
|
+
? lastAI.content
|
|
779
|
+
: '';
|
|
780
|
+
if (content.trim()) {
|
|
781
|
+
cleaned[cleaned.length - 1] = new HumanMessage(`[Context from orchestrator]: ${content}`);
|
|
782
|
+
}
|
|
783
|
+
else {
|
|
784
|
+
cleaned.pop();
|
|
785
|
+
}
|
|
786
|
+
}
|
|
767
787
|
return cleaned;
|
|
768
788
|
}
|
|
769
789
|
processTransferReception(messages, agentId) {
|