(https://gmpg.org/xfn/11) Agent Recursion · Choly's Blog (https://choly.ca/css/print.css) (https://choly.ca/css/poole.css) (https://choly.ca/css/syntax.css) (https://choly.ca/css/hyde.css) (https://fonts.googleapis.com/css?family=Abril+Fatface|PT+Sans:400,400i,700) (/apple-touch-icon-144-precomposed.png) (/favicon.png) (https://choly.ca/) Choly's Blog Documented Procrastination (https://choly.ca/) Home (https://github.com/icholy) Github (https://stackoverflow.com/users/215969/ilia-choly) Stack Overflow © 2025. All rights reserved. Agent Recursion Sun, May 18, 2025 When AI agents start using tools, the context window fills up fast. Each run_command or read_file tool call dumps a lot of text that quickly loses relevance in subsequent steps. I’ve been experimenting with the idea of “recursive agents” to mitigate this issue. The idea is simple: An agent can kick off new instances of itself to handle specific subtasks . The key part is that, when a child agent finishes, it doesn’t send its entire operational log or full tool output back to the parent; instead, it returns only a brief summary of the results. This does two important things: Keeps the parent agent’s context window usage down. Helps the parent agent stay focused on the overall objective. I’ve implemented this idea here: (https://github.com/icholy/sloppy) https://github.com/icholy/sloppy . The agent is simply provided with a run_agent tool. { "name" : "run_agent" , "description" : "Delegates a sub-task to a new child agent. Plan and break down work; use new, uniquely named agents for distinct sub-tasks or repetitive instances (min 3). Don't delegate the entire core task." , "parameters" : { "type" : "object" , "properties" : { "name" : { "type" : "string" , "description" : "A unique, short, and descriptive name for the child agent instance." }, "prompt" : { "type" : "string" , "description" : "Instructions for the new child agent, or follow-up questions for a previously created agent." } }, "required" : [ "name" , "prompt" ] } } Note : The description fields included here are abbreviated.