Skip to main content
A TeamFactory produces a fresh Team for each request. Register it in AgentOS(teams=[...]) alongside any prototype teams.
basic_team_factory.py
Run the team like any other team:
See the Factories reference for the full constructor signature and parameter list.

Members That Scale with the Caller

Member composition can change per request. A common pattern: scale team size and model quality with a subscription tier from ctx.trusted.claims.
The tier claim comes from verified middleware, so the tier cannot be changed by the request body. See Authorization From Verified Context for the trust model and JWT Role Factory for an end-to-end JWT example.

Async Factories

Use an async callable when you need to fetch context from a database, an HTTP service, or any other awaitable resource.
async_team_factory.py

With an Input Schema

Declare a Pydantic model on the factory to validate client-supplied factory_input before the factory runs.
team_factory_input.py
AgentFactory and TeamFactory instances cannot be passed inside members. Build per-member customization inside the team’s factory.

Error Handling

Raise FactoryPermissionError from inside the factory to reject unauthorized callers with HTTP 403. AgentOS raises FactoryValidationError (400) automatically when factory_input fails input_schema validation.
See the Factories reference for the full exception hierarchy and the post-resolve behavior.

Developer Resources