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