@illuma-ai/agents 1.1.23 → 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.
@@ -689,6 +689,25 @@ export class MultiAgentGraph extends StandardGraph {
689
689
  );
690
690
 
691
691
  try {
692
+ /**
693
+ * Dispatch transition BEFORE invoking the child subgraph so that
694
+ * callbacks.js sets multiAgentTrace.isMultiAgent = true before the
695
+ * child's ON_RUN_STEP events fire. This ensures child tool calls
696
+ * are attributed to the correct agent in admin traces.
697
+ */
698
+ await safeDispatchCustomEvent(
699
+ GraphEvents.ON_AGENT_TRANSITION,
700
+ {
701
+ sourceAgentId: sourceAgentId,
702
+ sourceAgentName: this.agentContexts.get(sourceAgentId)?.name ?? sourceAgentId,
703
+ destinationAgentId: destination,
704
+ destinationAgentName: destContext?.name ?? destination,
705
+ edgeType: EdgeType.HANDOFF,
706
+ timestamp: Date.now(),
707
+ },
708
+ config
709
+ );
710
+
692
711
  /**
693
712
  * Invoke the child subgraph with config propagation.
694
713
  * Config carries callbacks (for SSE streaming), abort signal,
@@ -711,19 +730,6 @@ export class MultiAgentGraph extends StandardGraph {
711
730
  `${truncatedResult.length < resultText.length ? `, truncated to ${truncatedResult.length}` : ''})`
712
731
  );
713
732
 
714
- await safeDispatchCustomEvent(
715
- GraphEvents.ON_AGENT_TRANSITION,
716
- {
717
- sourceAgentId: sourceAgentId,
718
- sourceAgentName: this.agentContexts.get(sourceAgentId)?.name ?? sourceAgentId,
719
- destinationAgentId: destination,
720
- destinationAgentName: destContext?.name ?? destination,
721
- edgeType: EdgeType.HANDOFF,
722
- timestamp: Date.now(),
723
- },
724
- config
725
- );
726
-
727
733
  return truncatedResult;
728
734
  } catch (err) {
729
735
  const errorMessage =