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

Open
opened 2026-02-16 18:18:34 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/11309

State: open
Merged: No


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).
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/11309 **State:** open **Merged:** No --- ### 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** ```bash 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).
yindo added the pull-request label 2026-02-16 18:18:34 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#13735