PyTest-Style Agent Functions¶
This example demonstrates a pytest-inspired way to work with agents:
- Using agents as function decorators
- Automatic function discovery
- Dependency injection
- Execution order control
- Function result handling
How It Works¶
- Functions are decorated with
@node_function
- Type hints specify which agent to inject (
analyzer: Agent
) - Dependencies are declared in the decorator (
depends_on="analyze_data"
) - Results from one function can be injected into another
- All functions are discovered and executed in the correct order
Key Features:
- Automatic agent injection based on type hints
- Function dependency resolution
- Parallel execution where possible
- Results passed automatically between functions
This provides a clean, declarative way to orchestrate multi-agent workflows, similar to how pytest fixtures work.