Sub-agents can reduce AI agent costs by delegating specific tasks to specialized agents using cheaper models. A 'find' sub-agent was implemented using Koog's agent-as-a-tool pattern, which searches codebases while keeping exploration context separate from the main agent. This approach achieved a 10% cost reduction ($1.63 to $1.47 per instance) while maintaining 58% success rate. The key insight is that using a cheaper model (GPT4.1 Mini) for the sub-agent drives savings, while natural context compression through task delegation alone doesn't reduce costs. The pattern mirrors software team structures where specialized roles handle distinct concerns, though effectiveness depends heavily on model selection and prompt engineering.

12m read timeFrom blog.jetbrains.com
Post cover image
Table of contents
The find agentBuilding a find sub-agentThe trade-offsThink wider: The engineering team analogyBenchmark results: Testing the hypothesisConclusion
520 Impressions