Function agency

  • Creates a multi-agent agency that coordinates a named roster of sub-agents using the specified orchestration strategy.

    The agency validates configuration immediately and throws an AgencyConfigError on any structural problem so issues surface at wiring time rather than the first call.

    Parameters

    • opts: AgencyOptions

      Full agency configuration including the agents roster, optional strategy, controls, hitl, and observability settings.

    Returns Agent

    An Agent instance whose generate / stream / session methods invoke the compiled strategy over the configured sub-agents.

    Throws

    When the configuration is structurally invalid (e.g. no agents defined, emergent enabled without hierarchical strategy, HITL approvals configured without a handler, parallel/debate without a synthesis model).