@illuma-ai/agents 1.1.22 → 1.1.24
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 +34 -8
- 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 +34 -8
- 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 +42 -13
- package/src/graphs/__tests__/multi-agent-delegate.test.ts +41 -27
- package/src/utils/llm.ts +1 -0
|
@@ -552,6 +552,20 @@ class MultiAgentGraph extends Graph.StandardGraph {
|
|
|
552
552
|
console.debug(`[MultiAgentGraph] Handoff "${sourceAgentId}" -> "${destination}" START ` +
|
|
553
553
|
`(messages: ${childMessages.length})`);
|
|
554
554
|
try {
|
|
555
|
+
/**
|
|
556
|
+
* Dispatch transition BEFORE invoking the child subgraph so that
|
|
557
|
+
* callbacks.js sets multiAgentTrace.isMultiAgent = true before the
|
|
558
|
+
* child's ON_RUN_STEP events fire. This ensures child tool calls
|
|
559
|
+
* are attributed to the correct agent in admin traces.
|
|
560
|
+
*/
|
|
561
|
+
await events.safeDispatchCustomEvent(_enum.GraphEvents.ON_AGENT_TRANSITION, {
|
|
562
|
+
sourceAgentId: sourceAgentId,
|
|
563
|
+
sourceAgentName: this.agentContexts.get(sourceAgentId)?.name ?? sourceAgentId,
|
|
564
|
+
destinationAgentId: destination,
|
|
565
|
+
destinationAgentName: destContext?.name ?? destination,
|
|
566
|
+
edgeType: _enum.EdgeType.HANDOFF,
|
|
567
|
+
timestamp: Date.now(),
|
|
568
|
+
}, config);
|
|
555
569
|
/**
|
|
556
570
|
* Invoke the child subgraph with config propagation.
|
|
557
571
|
* Config carries callbacks (for SSE streaming), abort signal,
|
|
@@ -563,14 +577,6 @@ class MultiAgentGraph extends Graph.StandardGraph {
|
|
|
563
577
|
console.debug(`[MultiAgentGraph] Handoff "${sourceAgentId}" -> "${destination}" DONE ` +
|
|
564
578
|
`(result: ${resultText.length} chars` +
|
|
565
579
|
`${truncatedResult.length < resultText.length ? `, truncated to ${truncatedResult.length}` : ''})`);
|
|
566
|
-
await events.safeDispatchCustomEvent(_enum.GraphEvents.ON_AGENT_TRANSITION, {
|
|
567
|
-
sourceAgentId: sourceAgentId,
|
|
568
|
-
sourceAgentName: this.agentContexts.get(sourceAgentId)?.name ?? sourceAgentId,
|
|
569
|
-
destinationAgentId: destination,
|
|
570
|
-
destinationAgentName: destContext?.name ?? destination,
|
|
571
|
-
edgeType: _enum.EdgeType.HANDOFF,
|
|
572
|
-
timestamp: Date.now(),
|
|
573
|
-
}, config);
|
|
574
580
|
return truncatedResult;
|
|
575
581
|
}
|
|
576
582
|
catch (err) {
|
|
@@ -766,6 +772,26 @@ class MultiAgentGraph extends Graph.StandardGraph {
|
|
|
766
772
|
}));
|
|
767
773
|
}
|
|
768
774
|
}
|
|
775
|
+
/**
|
|
776
|
+
* Ensure messages end with a HumanMessage.
|
|
777
|
+
* After stripping tool artifacts, the last message may be an AIMessage
|
|
778
|
+
* (orchestrator's reasoning before the handoff). Some providers (Bedrock,
|
|
779
|
+
* Google/VertexAI) reject conversations ending with an assistant message.
|
|
780
|
+
* Convert the trailing AIMessage to a HumanMessage to preserve any useful
|
|
781
|
+
* context (e.g., compacted tool summaries) while satisfying the API requirement.
|
|
782
|
+
*/
|
|
783
|
+
if (cleaned.length > 0 && cleaned[cleaned.length - 1].getType() === 'ai') {
|
|
784
|
+
const lastAI = cleaned[cleaned.length - 1];
|
|
785
|
+
const content = typeof lastAI.content === 'string'
|
|
786
|
+
? lastAI.content
|
|
787
|
+
: '';
|
|
788
|
+
if (content.trim()) {
|
|
789
|
+
cleaned[cleaned.length - 1] = new messages.HumanMessage(`[Context from orchestrator]: ${content}`);
|
|
790
|
+
}
|
|
791
|
+
else {
|
|
792
|
+
cleaned.pop();
|
|
793
|
+
}
|
|
794
|
+
}
|
|
769
795
|
return cleaned;
|
|
770
796
|
}
|
|
771
797
|
processTransferReception(messages$1, agentId) {
|