maestro-orchestrate icon indicating copy to clipboard operation
maestro-orchestrate copied to clipboard

Feat: Agent model settings with three quality presets

Open sea212 opened this issue 7 months ago • 4 comments

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.json which 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.md and 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.toml across all variants to prompt for quality mode selection and trigger the model setup.

📁 Infrastructure & Setup

  • .gitignore: Added .worktrees to the exclusion list.
  • Cross-Platform Sync: Synchronized changes across src/, claude/, and plugins/maestro/ to ensure consistent behavior across all Maestro entry points.

📒 Final Notes

  • Alternative approach to apply models considered: Gemini-Cli BeforeModel hook 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.js demands that setup-models.js and agent-modes.json exist identically in claude and plugins/maestro directory. This is nonsensical, as those files are gemini-specific. However, in orchestrate.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

sea212 avatar Apr 10 '26 21:04 sea212

@josstei Applied all suggestions, PR is ready for review.

sea212 avatar Apr 13 '26 05:04 sea212

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:61 mentions agents.overrides but 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 BeforeModel hook 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:

  1. agent-modes.json (containing Gemini-specific model IDs like gemini-3.1-pro-preview) gets copied to Claude and Codex payloads. The config/ prefix is in DETACHED_PAYLOAD_BASE_ALLOWLIST (src/generator/payload-builder.js:16), so everything under src/config/ ships to all runtimes.
  2. The setup_models MCP 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 avatar Apr 15 '26 02:04 josstei

@josstei Before beginning to work, please review the approach:

    • 2.: I'll hardcode acceptance of codebase_investigator in setup_models hook for Gemini only, instead of solely relying on KNOWN_AGENTS
  1. That's the correct approach
  2. 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
  3. 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.

sea212 avatar Apr 15 '26 05:04 sea212

@josstei Any updates?

sea212 avatar Apr 22 '26 10:04 sea212