feat: add coordinator agent with subagent-based worker dispatch#420
Merged
Conversation
Adds the autoship-coordinator skill and coordinator.sh that uses OpenCode's task tool to spawn general subagents per queued workspace. Supports task_id tracking, resume via existing task_ids, and configurable concurrency. Enable by calling coordinator.sh directly or via runner.sh with AUTOSHIP_COORDINATOR_MODE=true.
|
🎉 This PR is included in version 2.20.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces an AutoShip “coordinator” entrypoint intended to orchestrate queued workspaces by starting an OpenCode session that dispatches implementer subagents via the task tool, along with a skill document describing the coordinator workflow.
Changes:
- Added
hooks/opencode/coordinator.shto scan forQUEUEDworkspaces, generate a coordinator prompt, and start an OpenCode run for coordination. - Added
skills/autoship-coordinator/SKILL.mddocumenting the coordinator’s intended lifecycle, dispatch, and tracking behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
| skills/autoship-coordinator/SKILL.md | Adds a skill definition documenting the coordinator’s workflow and boundaries. |
| hooks/opencode/coordinator.sh | Adds a new hook script to batch queued workspaces and start an OpenCode coordinator session. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| *) echo "Unknown: $1"; exit 1 ;; | ||
| esac | ||
| done | ||
|
|
Comment on lines
+40
to
+45
| # Resolve max concurrency | ||
| MAX_CONCURRENT=5 | ||
| if [[ -f "$CONFIG_FILE" ]]; then | ||
| config_max=$(jq -r '.max_workers // .maxConcurrent // .max_concurrent // 5' "$CONFIG_FILE" 2>/dev/null || echo 5) | ||
| [[ "$config_max" =~ ^[0-9]+$ && "$config_max" -gt 0 ]] && MAX_CONCURRENT=$config_max | ||
| fi |
Comment on lines
+49
to
+67
| # Scan for QUEUED workspaces | ||
| queued=() | ||
| if [[ -d "$WORKSPACES_DIR" ]]; then | ||
| for ws_dir in "$WORKSPACES_DIR"/*/; do | ||
| [[ -d "$ws_dir" ]] || continue | ||
| s=$(tr -d '[:space:]' <"$ws_dir/status" 2>/dev/null || true) | ||
| [[ -f "$ws_dir/AUTOSHIP_PROMPT.md" && "$s" == "QUEUED" ]] && queued+=("$(basename "$ws_dir")") | ||
| done | ||
| fi | ||
|
|
||
| if [[ ${#queued[@]} -eq 0 ]]; then | ||
| log "No QUEUED workspaces. Exiting." | ||
| exit 0 | ||
| fi | ||
|
|
||
| log "Found ${#queued[@]} QUEUED: ${queued[*]}" | ||
|
|
||
| batch=("${queued[@]:0:$MAX_CONCURRENT}") | ||
| [[ "$DRY_RUN" == "true" ]] && { log "DRY-RUN: would start for ${batch[*]}"; exit 0; } |
Comment on lines
+102
to
+104
| opencode run --model "$COORDINATOR_MODEL" "$(cat "$COORDINATOR_PROMPT")" 2>&1 | tee -a "$LOG_FILE" | ||
|
|
||
| coordinator_exit=$? |
| coordinator_exit=$? | ||
| log "Coordinator exited with code $coordinator_exit" | ||
|
|
||
| [[ "$ONCE" == "false" ]] && { log "Re-scanning..."; exec bash "$0" --once; } |
|
|
||
| echo "" | ||
| echo "Concurrency cap: $MAX_CONCURRENT" | ||
| echo "Spare multiple subagents concurrently by calling task multiple times in one message." |
| AUTOSHIP_DIR="${AUTOSHIP_DIR:-.autoship}" | ||
| REPO_ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)" | ||
| WORKSPACES_DIR="$REPO_ROOT/$AUTOSHIP_DIR/workspaces" | ||
| STATE_FILE="$REPO_ROOT/$AUTOSHIP_DIR/state.json" |
|
🎉 This PR is included in version 2.21.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
coordinator.shhook — starts an OpenCode session that scans for QUEUED workspaces and spawns implementer subagents via thetasktoolautoship-coordinatorskill defining the coordinator workflowtask_idpersisted in<workspace>/task_idfor tracking and session-resumeAUTOSHIP_COORDINATOR_MODELenv var for coordinator model selectionmax_workers/max_concurrent)bash hooks/opencode/coordinator.shor setAUTOSHIP_COORDINATOR_MODE=truewith existing runner.shHow it works
The coordinator runs as an OpenCode agent that scans
.autoship/workspaces/*/for QUEUED workspaces and callstask(subagent_type=general, prompt=<prompt>)per workspace, replacing fire-and-forget background subshells with tracked subagents.