# Class InteractionSwarmObserver

SwarmObserver implementation.

#### Implements

- IInteractionObserver

- Defined in packages/nexus-agents/src/observability/swarm-observer.ts:53

##### Index

### Constructors

constructor

### Methods

generateTraceId
generateSpanId
recordEvent
recordInteraction
getCollaborationGraph
getBottlenecks
getEmergentClusters
attributeSuccess
getHealthMetrics
getEventsByTrace
getEventsByAgent
registerAgentForTask
clear

## Constructors

### constructor

- new InteractionSwarmObserver(
  config?: Partial<InteractionObserverConfig>,
  ): InteractionSwarmObserver

  #### Parameters

  - `Optional` config: Partial<InteractionObserverConfig>

  #### Returns InteractionSwarmObserver

  - Defined in packages/nexus-agents/src/observability/swarm-observer.ts:61

## Methods

### `Static` generateTraceId

- generateTraceId(): string

  Generate OpenTelemetry-compatible trace ID (32 hex chars).

  #### Returns string

  - Defined in packages/nexus-agents/src/observability/swarm-observer.ts:72

### `Static` generateSpanId

- generateSpanId(): string

  Generate OpenTelemetry-compatible span ID (16 hex chars).

  #### Returns string

  - Defined in packages/nexus-agents/src/observability/swarm-observer.ts:79

### recordEvent

- recordEvent(event: AgentEvent): void

  Record an agent event.

  #### Parameters

  - event: AgentEvent

  #### Returns void

  Implementation of IInteractionObserver.recordEvent

  - Defined in packages/nexus-agents/src/observability/swarm-observer.ts:86

### recordInteraction

- recordInteraction(options: RecordInteractionOptions): void

  Record an interaction between two agents.

  #### Parameters

  - options: RecordInteractionOptions

  #### Returns void

  Implementation of IInteractionObserver.recordInteraction

  - Defined in packages/nexus-agents/src/observability/swarm-observer.ts:97

### getCollaborationGraph

- getCollaborationGraph(): InteractionGraph

  Get the collaboration graph.

  #### Returns InteractionGraph

  Implementation of IInteractionObserver.getCollaborationGraph

  - Defined in packages/nexus-agents/src/observability/swarm-observer.ts:118

### getBottlenecks

- getBottlenecks(): BottleneckInfo[]

  Identify bottleneck agents.

  #### Returns BottleneckInfo[]

  Implementation of IInteractionObserver.getBottlenecks

  - Defined in packages/nexus-agents/src/observability/swarm-observer.ts:125

### getEmergentClusters

- getEmergentClusters(): AgentCluster[]

  Detect emergent clusters of collaborating agents. Uses strongly connected components + cohesion analysis.

  #### Returns AgentCluster[]

  Implementation of IInteractionObserver.getEmergentClusters

  - Defined in packages/nexus-agents/src/observability/swarm-observer.ts:152

### attributeSuccess

- attributeSuccess(taskId: string): Map<string, ContributionScore>

  Attribute success of a task to contributing agents.

  #### Parameters

  - taskId: string

  #### Returns Map<string, ContributionScore>

  Implementation of IInteractionObserver.attributeSuccess

  - Defined in packages/nexus-agents/src/observability/swarm-observer.ts:180

### getHealthMetrics

- getHealthMetrics(): SwarmHealthMetrics

  Get swarm health metrics.

  #### Returns SwarmHealthMetrics

  Implementation of IInteractionObserver.getHealthMetrics

  - Defined in packages/nexus-agents/src/observability/swarm-observer.ts:201

### getEventsByTrace

- getEventsByTrace(traceId: string): AgentEvent[]

  Get events for a specific trace.

  #### Parameters

  - traceId: string

  #### Returns AgentEvent[]

  Implementation of IInteractionObserver.getEventsByTrace

  - Defined in packages/nexus-agents/src/observability/swarm-observer.ts:230

### getEventsByAgent

- getEventsByAgent(agentId: string): AgentEvent[]

  Get events for a specific agent.

  #### Parameters

  - agentId: string

  #### Returns AgentEvent[]

  Implementation of IInteractionObserver.getEventsByAgent

  - Defined in packages/nexus-agents/src/observability/swarm-observer.ts:237

### registerAgentForTask

- registerAgentForTask(taskId: string, agentId: string): void

  Associate an agent with a task for attribution.

  #### Parameters

  - taskId: string
  - agentId: string

  #### Returns void

  - Defined in packages/nexus-agents/src/observability/swarm-observer.ts:244

### clear

- clear(): void

  Clear all recorded data.

  #### Returns void

  Implementation of IInteractionObserver.clear

  - Defined in packages/nexus-agents/src/observability/swarm-observer.ts:256