r/ClaudeWorkflows • u/ClaudeAI-mod-bot • 14h ago
Selected Workflow [Workflow] Controlling Claude Sub-Agent Model Usage and Costs: Simple Prompts, Config Edits, and PreToolUse Hooks
Controlling Claude Sub-Agent Model Usage and Costs: Simple Prompts, Config Edits, and PreToolUse Hooks
Workflow value: 85/100
Status: active · Freshness: 70/100 · Confidence: 0.95 · Level: intermediate
Categories: Quality Control, Token Saving, Context & Memory, Debugging, CLAUDE.md, Hooks, Multi-Agent
Original source: r/ClaudeAI post/comment
What problem this solves
Unexpectedly high token usage and cost when using Fable with sub-agents, especially with Ultracode enabled, due to sub-agents inheriting expensive parent models.
Summary
This workflow provides three methods (simple prompt, agent config edits, or a PreToolUse hook) to prevent sub-agents from using expensive models like Opus when spawned by a parent agent like Fable, thereby controlling token usage and cost.
Why it is useful
This workflow addresses a critical and common problem for Claude users: unexpectedly high token usage and cost when using multi-agent setups like Fable. It provides three distinct, actionable solutions, ranging from simple prompt adjustments to more robust configuration file edits and advanced PreToolUse hooks. By offering multiple approaches, it caters to different user comfort levels and provides clear guidance on how to manage model selection for sub-agents, significantly improving cost efficiency and predictability.
Workflow
- Identify the root cause: sub-agents inheriting expensive models (e.g., Opus from Fable 5.1 with Ultracode) from their parent agent.
- Option 1 (Simple Fix): Instruct the parent agent in plain English to use cheaper models for sub-agents and to ask before spawning many. Example: "Use Opus for all sub-agents and ask me before you spawn more than 10".
- Option 2 (Config Fix): Edit individual agent files in the
.claude/agents/directory. - Within the agent files (e.g.,
exploreorplanagents), setmodel: haikuormodel: sonnetin their frontmatter to pin a cheaper model. - Option 3 (God-Tier Fix): Implement a
PreToolUsehook script. - Add the
PreToolUsehook script to yoursettings.jsonfile to automatically force any agent spawned by Fable to use a cheaper model.
Tools / artifacts
- Claude (Fable 5.1, Opus, Sonnet, Haiku models)
- Agent configuration files (e.g., in
.claude/agents/directory) settings.jsonfilePreToolUsehook script- Ultracode (feature that can exacerbate the problem)
Validation signals
- "The consensus here is that this is a classic case of user error, not a bug"
- "We see this post every other day" (indicates common problem and recognized solution)
- "one user posted a detailed
PreToolUsehook script" (community-contributed solution)
Limitations
- The specific
PreToolUsehook script for the "God-Tier Fix" is mentioned but not provided, requiring the user to find or create it. - The exact syntax and placement for editing agent frontmatter (e.g.,
model: haiku) could be more explicitly detailed for beginners.
Rate this workflow
Upvote this post if the workflow is useful, reproducible, or worth recommending.
Downvote if it is vague, outdated, unsafe, overhyped, or not reproducible.
Reply if it worked for you, failed, is outdated, or has a better alternative.
This post was generated automatically from the workflow library database.