- Custom Logic: Implement complex business rules and data transformations
- Agent Integration: Call agents and teams within your custom processing logic
- Data Flow Control: Transform outputs between steps
Step with a custom function as the executor. A standard function accepts StepInput and returns StepOutput. Generator functions can yield executor events before yielding their final StepOutput.

Example
Class-based executor
You can also use a class-based executor by defining a class that implements the__call__ method.
- Configuration at initialization: Pass in settings, API keys, or behavior flags when creating the executor
- Stateful execution: Maintain state while the same executor instance is reused
- Reusable components: Create configured executor instances that can be shared across multiple workflows
__call__ method as an async function.
Streaming from a Custom Function
An async generator function can yield agent or team events followed by its finalStepOutput. AgentOS can then expose those events through the workflow stream.
Use
.arun() for an agent or team called from an async function executor.custom_function_step_async_stream.py
Streaming works the same way with a class-based executor. Define the
__call__ method to yield the events.Install the Streaming Dependencies
Set OpenAI Key
Set yourOPENAI_API_KEY as an environment variable. You can get one from OpenAI.
