Feat: Agent model settings with three quality presets
Related to #13
Description
This pull request introduces a system for configuring subagent models based on user-selectable model quality presets (quality, balanced, economic). The orchestrator now asks the user about the model quality preset and applies the model quality preset config in a project-specific settings.json via a newly introduced setup-models mcp. This allows for granular control over model selection for specialized subagents, enabling users to optimize for output quality or token efficiency.
Key Changes
🛠️ Subagent Model Mapping System
- Presets Config: Added
src/config/agent-modes.jsonwhich defines model mappings for all specialized agents across three modes:quality: Prioritizes high-tier models.balanced: A mix of Pro and Flash models.economic: Maximizes usage of lightweight Flash models.
- MCP Tool: Implemented
setup_models(src/mcp/handlers/setup-models.js) to apply these mappings to the project-local.gemini/settings.json. - Tool Integration: Registered the new functionality in the workspace tool pack.
🔄 Orchestration Workflow Enhancements
- New Step: Integrated a mandatory "Define Agent Models" step into both Standard and Express orchestration flows.
- Workflow Renumbering: Updated
src/references/orchestration-steps.mdand related platform variants to maintain sequential accuracy:- Step 11 (Standard) is now "Define Agent Models".
- Step 33 (Express) is now "Define Agent Models".
- Logic Updates: Modified
orchestrate.tomlacross all variants to prompt for quality mode selection and trigger the model setup.
📁 Infrastructure & Setup
.gitignore: Added.worktreesto the exclusion list.- Cross-Platform Sync: Synchronized changes across
src/,claude/, andplugins/maestro/to ensure consistent behavior across all Maestro entry points.
📒 Final Notes
- Alternative approach to apply models considered: Gemini-Cli
BeforeModelhook system. Currently blocked by https://github.com/google-gemini/gemini-cli/issues/21615 - "no (project-specific) settings.json write policy" broken. No other way to apply model configurations as of now.
- Review of model mapping highly recommended.
- In regards to #13 , users can now edit the generated settings.json (project-specific) or the extensions
agent-modes.json(global) to specify their own agent to model mappings. Orchestrator model-per-phase logic still tbd. zero_diff.test.jsdemands thatsetup-models.jsandagent-modes.jsonexist identically in claude and plugins/maestro directory. This is nonsensical, as those files are gemini-specific. However, inorchestrate.toml, Claude and Codex are instructed to do nothing when setting up agents, effectively rendering those nonsensical files useless in those cases.
Summary table of changes
| Category | Files Changed |
|---|---|
| New Features | src/config/agent-modes.json, src/mcp/handlers/setup-models.js |
| Workflows | src/references/orchestration-steps.md, claude/src/references/orchestration-steps.md, plugins/maestro/src/references/orchestration-steps.md |
| Commands | src/platforms/gemini/commands/maestro/orchestrate.toml, commands/maestro/orchestrate.toml (and others) |
| Infrastructure | .gitignore, src/mcp/tool-packs/workspace/index.js |
@josstei Applied all suggestions, PR is ready for review.
Analysis: Rebase Requirements and Open Design Questions
1. Registry Architecture Conflict (Critical — blocks merge)
src/core/agent-registry.js on main no longer has a hardcoded KNOWN_AGENTS array. It was replaced with auto-generated registries:
// src/core/agent-registry.js (main, lines 1-8)
const agentRegistryData = require('../generated/agent-registry.json');
const KNOWN_AGENTS = Object.freeze(
agentRegistryData.map((entry) => toSnakeCase(entry.name))
);
The registry is now built at generate-time by src/generator/registry-scanner.js, which scans src/agents/*.md and outputs src/generated/agent-registry.json. The CHANGELOG (Unreleased section) documents this: "Build-time auto-discovered registries — agent-registry.json, resource-registry.json, hook-registry.json scanned at generate time, replacing hardcoded allowlists."
The PR's changes to agent-registry.js (and the detached copies in claude/src/ and plugins/maestro/src/) patch code that no longer exists, which is why mergeable_state is "dirty".
Resolution path: On rebase, drop the agent-registry.js changes. To add codebase_investigator to the registry, create a definition file at src/agents/codebase-investigator.md so the scanner picks it up — but see the next section on whether that's the right approach.
2. codebase_investigator in the Agent Roster (Design Decision Needed)
No src/agents/codebase-investigator.md exists. There are 22 agent definitions in src/agents/, none for codebase_investigator (verified via src/generated/agent-registry.json).
The identifier refers to a platform built-in, not a Maestro-defined agent:
- On Gemini, it's a native Gemini CLI agent
- On Claude, it maps to
Agent (Explore) / Grep / Glob(src/platforms/claude/runtime-config.js:33) - On Codex, it maps to
local inspection or spawn_agent(src/platforms/codex/runtime-config.js:35)
Adding it to KNOWN_AGENTS has a side effect: validate_plan in src/mcp/handlers/validate-plan.js uses this list to check for unknown agents. Plans referencing codebase_investigator would go from triggering an "unknown agent" warning to being silently accepted, even though there's no Maestro methodology, tools list, or capabilities definition backing it.
Question: Is the intent to (a) create a Maestro agent definition wrapping the built-in, or (b) treat it as a special case in agent-modes.json only? If (b), it shouldn't be added to the agent registry.
3. agents.overrides Schema Verification (Should Confirm)
setup-models.js writes this structure to .gemini/settings.json:
{
"agents": {
"overrides": {
"coder": {
"modelConfig": { "model": "gemini-3.1-pro-preview" }
}
}
}
}
No documentation within this codebase confirms modelConfig: { model } is the correct Gemini CLI schema for agent overrides:
GEMINI.md:61mentionsagents.overridesbut doesn't document its structure- CHANGELOG v1.3.0 says model tuning uses "agent frontmatter and Gemini CLI
agents.overrides" but provides no schema - The
BeforeModelhook was removed because "Gemini CLI discards model field from hook output" (CHANGELOG v1.1.1, Removed section)
If the schema doesn't match what Gemini CLI expects, the feature silently has no effect — Gemini CLI ignores unrecognized keys, and users see no model changes after restart. Has this been validated against Gemini CLI's settings parser?
4. Cross-Runtime Cleanup (Not Blocking)
Two artifacts ship to non-Gemini runtimes unnecessarily:
agent-modes.json(containing Gemini-specific model IDs likegemini-3.1-pro-preview) gets copied to Claude and Codex payloads. Theconfig/prefix is inDETACHED_PAYLOAD_BASE_ALLOWLIST(src/generator/payload-builder.js:16), so everything undersrc/config/ships to all runtimes.- The
setup_modelsMCP tool is registered for all runtimes, even though it writes to.gemini/settings.json.
Options: exclude agent-modes.json from non-Gemini payloads, or have setup_models return early with a message when the runtime is not Gemini.
5. Restart UX (Minor)
The mandatory restart at step 11 (Standard) / step 33 (Express) interrupts the workflow mid-phase. In Standard mode, it falls after entering Plan Mode but before the design dialogue — conversational context is lost on restart.
The PR notes this is blocked by the BeforeModel hook approach (gemini-cli#21615). If a restart remains unavoidable, moving the model setup step to the very beginning of the workflow (before Plan Mode entry) would minimize context loss. Tradeoff: model selection happens before the task is understood, but since all 23 agents are configured regardless, timing doesn't change the outcome.
Summary
| Issue | Severity | Blocks Merge? |
|---|---|---|
| Registry architecture conflict | Critical | Yes — requires rebase + strategy change |
codebase_investigator identity |
Significant | Needs design decision |
agents.overrides schema unverified |
Significant | Should confirm before merge |
| Cross-runtime artifact cleanup | Low | No |
| Restart UX / step placement | Low | No |
Generated by Claude Code
@josstei Before beginning to work, please review the approach:
-
- 2.: I'll hardcode acceptance of
codebase_investigatorinsetup_modelshook for Gemini only, instead of solely relying onKNOWN_AGENTS
- 2.: I'll hardcode acceptance of
- That's the correct approach
- I'll try to figure out a way that the config and MCP are not copied or are a NOOP for other runtimes than Gemini right now
- As it is right now, it only happens in Gemini environment. I'll try to preserve that. Gemini allows to restore session context
as a side note, I think trying to create the golden hen that works in every agent runtime is destined to fail. From my experience from countless other tools, it just massively bloats the codebase and doesn't work properly for runtimes other than the one it was originally designed for. Building multiples standalone tools that are crafted for one runtime each and that respect the runtimes own way of dealing with processes is the way to go. Everything else just becomes a Frankenstein patchwork that massively complicates maintenance and doesn't work properly in all runtimes anyways.
@josstei Any updates?