agent_os and injects the active instance. At startup this example appends a second agent and calls agent_os.resync(app) so the discovery document and routers reflect the updated component set. Shutdown uses the same lifespan for cleanup.
lifespan.py
Run the Example
1
Set up your virtual environment
2
Install dependencies
3
Export your OpenAI API key
4
Run the example
Save the code above as
lifespan.py, then run: