# Function createTrackedAgent

- createTrackedAgent(
  agentId: string,
  state: "error" | "thinking" | "idle" | "waiting" | "executing",
  role?: string,
  currentTask?: string,
  ): ObserverTrackedAgent

  Creates a new TrackedAgent object with initial values.

  #### Parameters

  - agentId: string

    The agent ID

  - state: "error" | "thinking" | "idle" | "waiting" | "executing"

    The initial agent state

  - role: string = 'unknown'

    The agent role (defaults to 'unknown')

  - `Optional` currentTask: string

    Optional current task description

  #### Returns ObserverTrackedAgent

  A new TrackedAgent object

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