Skip to content

Add opencode agent backend - #43

Open
0xnavarro wants to merge 2 commits into
unclebob:mainfrom
0xnavarro:feat/opencode-backend
Open

Add opencode agent backend#43
0xnavarro wants to merge 2 commits into
unclebob:mainfrom
0xnavarro:feat/opencode-backend

Conversation

@0xnavarro

Copy link
Copy Markdown

Summary

Adds opencode as a supported agent backend, following the existing codex launch pattern:

  • swarmforge.bb: accepts opencode in the agent allowlist and launches opencode run --dir <worktree> <extra args> "$(cat <role prompt>)".
  • Model selection is config-driven, never hardcoded: per-role via extra CLI args (--model provider/model-id) or globally via SWARMFORGE_MODEL for all opencode roles; a per-role --model takes precedence.
  • README documents the opencode config line.
  • Launcher tests cover the initial prompt, extra CLI args, the SWARMFORGE_MODEL default, and per-role override precedence.

Validation

bb test: 28 tests / 100 assertions, 0 failures.

Scope is deliberately limited to the opencode backend (no other backends, no default model, no auto-approve flags baked in). Related discussion: #39.

Add opencode to the supported agent backends, launching one-shot
'opencode run' in the role worktree with the generated role prompt.
Provider/model selection passes through extra CLI args (--model), and
SWARMFORGE_MODEL sets a default model for opencode roles when no
per-role --model is given.

Add launcher tests covering the initial prompt, extra CLI args, the
SWARMFORGE_MODEL default, and per-role override precedence.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9eaf90b41c

ℹ️ 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".

Comment thread swarmforge/scripts/swarmforge.bb Outdated
"copilot" (str "copilot -C " (sq (str role-worktree)) " --name " (sq (str "SwarmForge " display)) " " (extra-args-prefix row) "-i \"$(cat " (sq (str prompt-file)) ")\"")
"grok" (str "grok --cwd " (sq (str role-worktree)) " " (grok-permission-prefix row) (extra-args-prefix row) "--rules \"$(cat " (sq (str prompt-file)) ")\" --verbatim \"$(cat " (sq (str prompt-file)) ")\"")))
"grok" (str "grok --cwd " (sq (str role-worktree)) " " (grok-permission-prefix row) (extra-args-prefix row) "--rules \"$(cat " (sq (str prompt-file)) ")\" --verbatim \"$(cat " (sq (str prompt-file)) ")\"")
"opencode" (str "opencode run --dir " (sq (str role-worktree)) " " (opencode-model-arg row) (extra-args-prefix row) "\"$(cat " (sq (str prompt-file)) ")\"")))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Launch opencode in a persistent mode

For configurations where a role uses opencode, this invokes opencode run, which the OpenCode CLI docs describe as the non-interactive scripting mode (opencode run [message..], with --dir as a run flag: https://opencode.ai/docs/cli/#run). SwarmForge depends on the tmux agent process staying alive to receive later handoffs, and the first window appends cleanup immediately after the agent exits; an opencode first role will complete the initial prompt and tear down the swarm, while later opencode roles will simply stop instead of waiting for work. Use the persistent TUI entrypoint with an initial prompt/project directory, or another long-running opencode mode, for swarm roles.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in e268a54: opencode roles now launch the persistent TUI entrypoint (opencode <worktree> --prompt "$(cat <role prompt>)") instead of one-shot opencode run, so the agent process stays alive to receive handoff wake-ups. Added a regression assertion that the launch command does not use opencode run. Verified with bb test (28 tests / 101 assertions).

opencode run is the one-shot scripting mode: the agent completes the
initial prompt and exits, which would tear down the first (cleanup)
window and leave later roles stopped instead of waiting for work.
Launch the persistent TUI entrypoint instead, injecting the role
prompt with --prompt so the process stays alive to receive handoff
wake-ups, matching the claude and copilot interactive backends.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant