Skip to main content

Function: agency()

Call Signature​

agency(opts): AgencyInstance<PanelResult>

Defined in: packages/agentos/src/api/agency.ts:205

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.

With a modelPool or strategy: 'panel', every call is guarded, seated and masked: a per-call option that would move every seat off its seating is refused, the roster is seated from the pool, and no credential the call can send reaches a record, a thrown error or a callback.

Parameters​

opts​

AgencyOptions & object

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

Returns​

AgencyInstance<PanelResult>

An AgencyInstance whose generate / stream / session methods invoke the compiled strategy over the configured sub-agents; generate() resolves to a PanelResult for a panel agency.

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).

Throws​

For a panel whose roster names a seat 'chair'.

Call Signature​

agency(opts): AgencyInstance

Defined in: packages/agentos/src/api/agency.ts:215

Creates a multi-agent agency: the same factory, for any strategy. See the overload above for what it validates and returns.

Parameters​

opts​

AgencyOptions

Full agency configuration.

Returns​

AgencyInstance

An AgencyInstance whose generate() resolves to an AgencyResult.

Throws​

When the configuration is structurally invalid.

Throws​

For a panel whose roster names a seat 'chair'.