Skip to content

Comments

feat: add autonomous coach-player mode for improved code quality (It's the Goose 3 CLI coding model)#11309

Open
chaollapark wants to merge 1 commit intoanomalyco:devfrom
chaollapark:feat/autonomous-coach-player-mode
Open

feat: add autonomous coach-player mode for improved code quality (It's the Goose 3 CLI coding model)#11309
chaollapark wants to merge 1 commit intoanomalyco:devfrom
chaollapark:feat/autonomous-coach-player-mode

Conversation

@chaollapark
Copy link

What does this PR do?

Adds an autonomous coach-player adversarial feedback loop to OpenCode CLI (opencode autonomous) to improve implementation quality via iterative critique.

Inspired by Block's Goose 3 "adversarial cooperation" approach:
https://block.xyz/documents/adversarial-cooperation-in-code-synthesis.pdf

Roles

  • Player agent: implements requirements, writes code, creates files
  • Coach agent: reviews, critiques, finds gaps, suggests fixes (fresh instance each turn to reduce context drift)

Key features

  • --max-turns configurable (default: 5)
  • Separate models for player and coach
  • Per-turn metrics (token usage + duration)
  • Explicit approval signal (IMPLEMENTATION_APPROVED) for reliable stop condition
  • --format json output for scripting/automation

Usage

opencode autonomous requirements.md
opencode autonomous "Build a CLI" --max-turns 10
opencode autonomous req.md -p anthropic/claude-3-5-sonnet -c openai/gpt-4o

Code layout

  • Added: packages/opencode/src/autonomous/* (types, player, coach, loop/index)
  • Added: packages/opencode/src/cli/cmd/autonomous.ts
  • Added: packages/opencode/test/autonomous/autonomous.test.ts
  • Modified: packages/opencode/src/index.ts (command registration)

How did you verify your code works?

Automated

  • Ran unit tests (including packages/opencode/test/autonomous/autonomous.test.ts)
  • Ran typecheck
  • Ran lint/format

Manual smoke tests

  • opencode autonomous requirements.md completes successfully
  • --max-turns 1 stops after 1 turn
  • Coach approval (IMPLEMENTATION_APPROVED) exits early
  • --format json prints valid JSON and includes per-turn metrics
  • Invalid args / missing file paths return a clear error + non-zero exit code

Notes

  • Coach is instantiated fresh each turn to avoid accumulating bias/context.
  • Network/provider calls are mocked in tests (so CI doesn't spend money or flake).

Implements a coach-player adversarial feedback loop that improves code
quality by having two agents with opposing objectives work together:

- Player agent: implements requirements, writes code
- Coach agent: reviews, critiques, finds gaps (fresh instance each turn)

Key features:
- Configurable max turns (default: 5)
- Different models for player vs coach
- Metrics tracking (tokens, duration per turn)
- Clear approval signal detection
- JSON output format for scripting

Usage:
  opencode autonomous requirements.md
  opencode autonomous "Build a CLI" --max-turns 10
  opencode autonomous req.md -p anthropic/claude-3-5-sonnet -c openai/gpt-4o

Files added:
- packages/opencode/src/autonomous/ (types, player, coach, index)
- packages/opencode/src/cli/cmd/autonomous.ts
- packages/opencode/test/autonomous/autonomous.test.ts
@github-actions
Copy link
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions
Copy link
Contributor

The following comment was made by an LLM, it may be inaccurate:

Potential Duplicate Found

PR #9312: feat: add ralph-loop for autonomous task completion

Why it might be related: This PR also addresses autonomous task completion with an iterative loop mechanism. While it may use different implementation details ("ralph-loop" vs "coach-player mode"), both PRs appear to tackle similar autonomous execution patterns. Worth reviewing to ensure there's no overlapping functionality or conflicting approaches.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant