Add diverge strategy for parallel agent generation with cognitive stances#9
Add diverge strategy for parallel agent generation with cognitive stances#9AaronGoldsmith wants to merge 3 commits intomainfrom
Conversation
…e ranking Introduces a new agent creation method that spawns N parallel Opus calls, each seeded with a different cognitive stance (minimalist, lateral, systems, naive, adversarial), then optionally ranks them via the judge panel before registration. This produces genuinely diverse agents from a single task. - Add `stance` field to AgentRecord (models.py) + DB migration (db.py) - Add `AgentBuilder.diverge()` with parallel async generation + judge ranking - Add `mobius diverge "<task>" --n 5 --no-judge` CLI command - Add `--strategy diverge --task "<task>"` flag to `mobius bootstrap` https://claude.ai/code/session_012PH76ua8FpCuomTWXS1B9W
There was a problem hiding this comment.
Pull request overview
Adds a new “diverge” agent-generation strategy that spawns multiple agents in parallel using different cognitive stances, persists the stance in the DB/model, optionally judge-ranks candidates, and exposes the workflow via CLI.
Changes:
- Add
stancetoAgentRecordand persist it in SQLite (including a migration for existing DBs). - Implement
AgentBuilder.diverge()to generate N agents concurrently across predefined cognitive stances and optionally rank them viaJudgePanel. - Extend CLI:
mobius bootstrap --strategy diverge ...and add a newmobius diverge ...command.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
src/mobius/models.py |
Adds stance field to the agent record model. |
src/mobius/db.py |
Adds stance column to schema and a migration for existing DBs. |
src/mobius/cli.py |
Adds bootstrap diverge strategy options and introduces mobius diverge command. |
src/mobius/agent_builder.py |
Implements parallel stance-based generation and optional judge ranking. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/mobius/cli.py
Outdated
| task: str = typer.Argument(..., help="Task description to generate diverse agents for"), | ||
| n: int = typer.Option(5, "--n", "-n", help="Number of divergent agents to generate"), | ||
| no_judge: bool = typer.Option(False, "--no-judge", help="Skip judge ranking — register all candidates"), | ||
| verbose: bool = typer.Option(False, "--verbose", "-v"), |
src/mobius/agent_builder.py
Outdated
| provider=data.get("provider", "anthropic"), | ||
| model=data.get("model", "claude-haiku-4-5-20251001"), | ||
| tools=data.get("tools", ["Bash", "Read", "Grep", "Glob"]), | ||
| specializations=data.get("specializations", []), | ||
| stance=stance_name, |
src/mobius/cli.py
Outdated
| def bootstrap( | ||
| strategy: str = typer.Option("default", "--strategy", "-s", help="Strategy: 'default' (sequential specializations) or 'diverge' (parallel stances)"), | ||
| task: str = typer.Option(None, "--task", "-t", help="Task description (required for --strategy diverge)"), | ||
| n: int = typer.Option(5, "--n", "-n", help="Number of agents for diverge strategy"), |
src/mobius/cli.py
Outdated
| task: str = typer.Option(None, "--task", "-t", help="Task description (required for --strategy diverge)"), | ||
| n: int = typer.Option(5, "--n", "-n", help="Number of agents for diverge strategy"), |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1aecc4bacc
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
src/mobius/cli.py
Outdated
| agent.is_champion = True # First of their kind = champion | ||
| registry.create_agent(agent) | ||
| console.print(f"[green]Created: {agent.name} ({agent.provider}/{agent.model})[/green]") | ||
| if strategy == "diverge": |
There was a problem hiding this comment.
Reject unknown bootstrap strategies
The new --strategy flag is documented in the option help as a two-mode switch (default or diverge), but the implementation only checks strategy == "diverge" and silently falls back to default for every other value. A typo like --strategy divergee will run sequential bootstrap instead of failing, which can invalidate experiment setup while still consuming provider calls. Please validate strategy against the supported set and exit with an error on unknown values.
Useful? React with 👍 / 👎.
src/mobius/cli.py
Outdated
| if registry.get_agent_by_slug(agent.slug): | ||
| console.print(f"[yellow]Skipping {agent.slug} — already exists[/yellow]") | ||
| continue | ||
| agent.is_champion = (i == 0) # Judge winner is champion | ||
| registry.create_agent(agent) |
There was a problem hiding this comment.
Promote first inserted diverged agent to champion
In the diverge bootstrap flow, slug conflicts are skipped before champion assignment is applied by index, so if the top-ranked candidate already exists, every newly inserted agent gets is_champion=False. This means a judged bootstrap run can register zero champions even when it successfully generated alternatives, which breaks the command’s stated winner-promotion behavior for reruns or partially seeded registries.
Useful? React with 👍 / 👎.
…ith judge ranking" This reverts commit 1aecc4b.
Enables skills (like /mobius-seed) to search the agent registry semantically before creating new agents, avoiding duplicates at scale (50-10k+ agents). Embeds agent descriptions at creation time using sentence-transformers + sqlite-vec. - Add agent_vec virtual table to db.py schema - Embed agent descriptions on create in registry.py - Add find_agents.py script for vec-based agent search - Update /mobius-seed skill to use semantic search - Pass vec_available through to Registry constructors Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
What
Adds a new
diverge()method to AgentBuilder that generates N agents in parallel, each approaching the same task through a distinct cognitive stance (minimalist, lateral, systems, naive, adversarial). Includes optional judge-based ranking and a new CLI command to invoke this strategy.Why
The existing
bootstrap()method generates agents sequentially with predefined specializations. This PR enables exploration of solution diversity by spawning multiple agents with different thinking styles in parallel, allowing the system to discover novel approaches and compare their effectiveness. The judge panel can rank candidates by prompt quality, promoting the best to champion status.How to test
pytest tests/ -vpassesmobius diverge "write a Python CLI tool" --n 5generates 5 agents with different stancesmobius bootstrap --strategy diverge --task "..." --n 3seeds initial agents via divergestancefield populated in databasehttps://claude.ai/code/session_012PH76ua8FpCuomTWXS1B9W