Resource Cleanup: Preventing Orphaned Agent Processes
Ensuring temporary files, connections, and processes are terminated after task completion.
Steps
- Use context managers for all tool executions.
- Implement a global cleanup hook for agent exits.
- Tag temporary files with unique session IDs.
- Set TTLs on cloud-hosted temporary resources.
- Run a recurring ghost-process reaper.