run_hooks_in_background at the AgentOS level.
1
Create a Python file
background_hooks_global.py
2
Set up your virtual environment
3
Install dependencies
4
Export your OpenAI API key
5
Run the server
6
Test the endpoint
What Happens
- The agent processes the request
- The response is sent immediately to the user
- All pre-hooks and post-hooks run in the background
- The user doesn’t have to wait for these tasks to complete
With
run_hooks_in_background=True on AgentOS, all hooks for all agents run in the background. Use the @hook decorator for more granular control over which hooks run in the background.