-
Notifications
You must be signed in to change notification settings - Fork 0
Add free subagent-based competition mode to /mobius-run #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
d5cf598
Add free subagent-based competition mode to /mobius-run
AaronGoldsmith a9d864d
Address PR review feedback and improve README
AaronGoldsmith 0b89406
Fix record_outputs.py to read from stdin
AaronGoldsmith fbebfb8
Fix Windows charmap encoding error for stdin
AaronGoldsmith File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| """Create a match record for a free (subagent-based) competition. | ||
|
|
||
| Usage: | ||
| python create_match.py "<task>" [--agents <slug1,slug2,...>] [--count N] | ||
|
|
||
| Modes: | ||
| --agents slug1,slug2 Use specific agents from registry by slug | ||
| --count N Pick top N agents by Elo (default: 5) | ||
|
|
||
| Outputs JSON with match_id and agent details for the skill to orchestrate. | ||
| """ | ||
AaronGoldsmith marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| import json | ||
| import sys | ||
|
|
||
| sys.path.insert(0, "src") | ||
|
|
||
| from mobius.config import get_config | ||
| from mobius.db import init_db | ||
| from mobius.models import MatchRecord | ||
| from mobius.registry import Registry | ||
|
|
||
|
|
||
| def main(): | ||
| args = sys.argv[1:] | ||
| if not args: | ||
| print("Usage: python create_match.py '<task>' [--agents s1,s2] [--count N]") | ||
| sys.exit(1) | ||
|
|
||
| task = args[0] | ||
| slugs = None | ||
| count = 5 | ||
|
|
||
| i = 1 | ||
| while i < len(args): | ||
| if args[i] == "--agents" and i + 1 < len(args): | ||
| slugs = [s.strip() for s in args[i + 1].split(",")] | ||
AaronGoldsmith marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| i += 2 | ||
| elif args[i] == "--count" and i + 1 < len(args): | ||
| count = int(args[i + 1]) | ||
| i += 2 | ||
| else: | ||
| i += 1 | ||
|
|
||
AaronGoldsmith marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| config = get_config() | ||
| conn, _ = init_db(config) | ||
| registry = Registry(conn, config) | ||
|
|
||
| # Select agents | ||
| agents = [] | ||
| if slugs: | ||
| for slug in slugs: | ||
| agent = registry.get_agent_by_slug(slug) | ||
| if agent: | ||
| agents.append(agent) | ||
| else: | ||
| print(f"Warning: agent '{slug}' not found, skipping", file=sys.stderr) | ||
| else: | ||
| all_agents = registry.list_agents() | ||
| all_agents.sort(key=lambda a: a.elo_rating, reverse=True) | ||
| agents = all_agents[:count] | ||
|
|
||
| if len(agents) < 2: | ||
| print(json.dumps({"error": "Need at least 2 agents", "agent_count": len(agents)})) | ||
| sys.exit(1) | ||
|
|
||
| # Create match record (outputs empty — skill will fill them) | ||
| match = MatchRecord( | ||
| task_description=task, | ||
| competitor_ids=[a.id for a in agents], | ||
| ) | ||
|
|
||
| conn.execute( | ||
| """INSERT INTO matches (id, task_description, competitor_ids, outputs, judge_models, | ||
| judge_reasoning, winner_id, scores, voided, created_at) | ||
| VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)""", | ||
| ( | ||
| match.id, | ||
| match.task_description, | ||
| json.dumps(match.competitor_ids), | ||
| json.dumps({}), | ||
| json.dumps([]), | ||
| "", | ||
| None, | ||
| json.dumps({}), | ||
| 0, | ||
AaronGoldsmith marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| match.created_at.isoformat(), | ||
| ), | ||
| ) | ||
| conn.commit() | ||
|
|
||
| # Output agent details for the skill | ||
| result = { | ||
| "match_id": match.id, | ||
| "task": task, | ||
| "agents": [ | ||
| { | ||
| "id": a.id, | ||
| "name": a.name, | ||
| "slug": a.slug, | ||
| "system_prompt": a.system_prompt, | ||
| "specializations": a.specializations, | ||
| "elo_rating": a.elo_rating, | ||
| } | ||
| for a in agents | ||
| ], | ||
| } | ||
|
|
||
| print(json.dumps(result, indent=2)) | ||
| conn.close() | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| """Record agent outputs for a free competition match. | ||
|
|
||
| Usage: | ||
| echo "output text" | python record_outputs.py <match_id> <agent_id> | ||
| echo '{"id1": "out1", "id2": "out2"}' | python record_outputs.py <match_id> --bulk | ||
|
|
||
| Reads output from stdin to avoid shell escaping issues. | ||
| """ | ||
AaronGoldsmith marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| import json | ||
| import sys | ||
|
|
||
| sys.path.insert(0, "src") | ||
|
|
||
| from mobius.config import get_config | ||
| from mobius.db import init_db | ||
|
|
||
|
|
||
| def main(): | ||
| if len(sys.argv) < 3: | ||
| print("Usage:", file=sys.stderr) | ||
| print(" echo 'output' | python record_outputs.py <match_id> <agent_id>", file=sys.stderr) | ||
| print(" echo '{...}' | python record_outputs.py <match_id> --bulk", file=sys.stderr) | ||
| sys.exit(1) | ||
|
|
||
| match_id = sys.argv[1] | ||
| mode = sys.argv[2] | ||
| sys.stdin.reconfigure(encoding="utf-8", errors="replace") | ||
| stdin_data = sys.stdin.read() | ||
|
|
||
| config = get_config() | ||
| conn, _ = init_db(config) | ||
|
|
||
| row = conn.execute( | ||
| "SELECT id, outputs FROM matches WHERE id LIKE ?", (f"{match_id}%",) | ||
| ).fetchone() | ||
| if not row: | ||
| print(f"Match '{match_id}' not found.", file=sys.stderr) | ||
| sys.exit(1) | ||
|
|
||
| full_id = row[0] | ||
| existing = json.loads(row[1]) if row[1] else {} | ||
|
|
||
| if mode == "--bulk": | ||
| new_outputs = json.loads(stdin_data) | ||
| existing.update(new_outputs) | ||
| else: | ||
| agent_id = mode | ||
| existing[agent_id] = stdin_data.strip() | ||
|
|
||
| conn.execute( | ||
| "UPDATE matches SET outputs = ? WHERE id = ?", | ||
| (json.dumps(existing), full_id), | ||
| ) | ||
| conn.commit() | ||
AaronGoldsmith marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| print(f"Recorded {len(existing)} outputs for match {full_id[:8]}") | ||
| conn.close() | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.