Agent, Team, or Workflow per request. AgentFactory, TeamFactory, and WorkflowFactory are thin subclasses of BaseFactory[T] and share the same constructor; they differ only in the component type produced.
Import
Parameters
Shared constructor signature forAgentFactory, TeamFactory, and WorkflowFactory:
After the factory returns, AgentOS enforces the component’s
id to match the factory’s id, fills the component’s db from the factory if unset, sets store_events=True so per-step run events persist on the run output, and runs the component-specific initialize_*().
RequestContext
AgentOS passes aRequestContext as the sole argument to every factory call.
factory_input by endpoint
Identity precedence
user_id and session_id follow the same precedence as the prototype path. Verified middleware wins over the form field. On POST /runs, if both are set and disagree, the form value is overridden and a warning is logged.
request.state.user_id/request.state.session_idset by verified middleware (e.g.JWTMiddlewarelifting thesubclaim). Wins if present.- Explicit form field on the run request. Used only when no verified value is set.
None.
Exceptions
All factory exceptions inherit fromFactoryError. The router maps them to HTTP status codes:
Usage
Mixing Factories and Prototypes
Sending factory_input
See Also
- Factories overview - Conceptual overview
- AgentFactory - Build an Agent per request
- TeamFactory - Build a Team per request
- WorkflowFactory - Build a Workflow per request
- Factory examples - Runnable examples mirroring the cookbook