Code 2025
Hacking Subagents Into Codex CLI — Brian John, Betterup
Overview
This talk explores a method for integrating sub-agents into the CodeX CLI, enabling users to leverage existing workflows with alternative tools. The core idea is to create a wrapper script that manages the execution of child CodeX processes as sub-agents, allowing them to perform tasks and return results to the parent session. This approach aims to overcome the limitations of being locked into a single tool or model family while retaining the benefits of sub-agent context management.
Who should watch
- AI Engineers looking to extend the capabilities of their CLI tools.
- Developers who want to use sub-agents with tools other than their primary AI assistant.
- Builders seeking to integrate complex workflows into their development process.
- Those encountering limitations with single-model or single-tool agent systems.
Key takeaways
- Sub-agents are valuable for context management, allowing child agents to consume tokens without impacting the main agent's context window.
- A simple wrapper script can facilitate the execution of sub-agents within the CodeX CLI by managing prompts and file I/O.
- Configuring CodeX CLI permissions for sub-agents is the most challenging aspect, requiring careful balancing of sandbox settings and disabling features like the rollout recorder.
- To maintain consistent permissions, agent names and queries are written to files rather than passed as command arguments, avoiding repeated permission prompts.
- The "agents rule of two" security framework from Meta can help assess the risk associated with agent execution, particularly concerning access to sensitive systems and data.
- Defining sub-agents in an `agents.md` file allows CodeX to understand how to invoke them, including specifying reasoning effort and prompts.
- The provided proof-of-concept repository is open-source and demonstrates the implementation with toy agents for tasks like word counting and file writing.
- CodeX CLI executes sub-agent tasks serially, which is slower than asynchronous execution but aligns with its design as a more hands-off tool.
Notable quotes
*The main agent can give a problem to a sub agent. It can go off, do its work, use its tokens, and pass just the answer back to the main agent.*
*Figuring out the minimum required permissions is probably the hardest part about this.*
*Lower risk does not mean no risk. So your mileage may vary here. You need to make your own determination on if this is something you feel comfortable with.*
Unofficial community note. Prefer the recording for nuance.