fix: Enforce Terminal Commit Contract for Delegated Workers#46
Merged
tctinh merged 1 commit intotctinh:mainfrom Feb 15, 2026
Merged
Conversation
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.
PR: Enforce Terminal Commit Contract for Delegated Workers
Summary
This PR fixes a contract gap between Forager workers and
hive_worktree_commitby making completion semantics explicit and machine-readable.Before this change, workers were told to stop immediately after calling
hive_worktree_commit, but the tool could return a non-terminal rejection (for example missing verification evidence). That could leave tasks inin_progresswith an apparently silent worker finish. This confuses the orchestrator greatly.After this change:
hive_worktree_commitalways returns structured JSONok=true,terminal=true)in_progressProblem
The previous flow had conflicting rules:
This mismatch caused ambiguous worker endings and required manual interpretation of task state.
What Changed
1) Structured completion contract in
hive_worktree_commithive_worktree_commitnow always returns JSON with control-flow fields:okterminalstatustaskStatenextActionNon-terminal outcomes (for example
verification_required,commit_failed) returnok: false,terminal: false, with explicit next action.Terminal outcomes (
completed,blocked,failed,partial) returnok: true,terminal: true.2) Worker completion logic updated
Forager and worker prompt guidance now requires inspecting commit response semantics:
nextActionand retry commit3) Orchestrator invariant added
Hive and Swarm prompts now enforce that after blocking
task()return, delegated task state must not remainin_progress.If it remains
in_progress, orchestrator treats it as non-terminal completion and resumes/retries worker with explicit commit-response handling.4) Tests and docs
Files Updated
packages/opencode-hive/src/index.tspackages/opencode-hive/src/utils/worker-prompt.tspackages/opencode-hive/src/agents/forager.tspackages/opencode-hive/src/agents/hive.tspackages/opencode-hive/src/agents/swarm.tspackages/opencode-hive/src/agents/prompts.test.tspackages/opencode-hive/src/utils/worker-prompt.test.tspackages/opencode-hive/src/e2e/plugin-smoke.test.tspackages/opencode-hive/docs/HIVE-TOOLS.mdValidation Run
bun test src/agents/prompts.test.ts src/utils/worker-prompt.test.ts src/e2e/plugin-smoke.test.ts(pass)bun run buildinpackages/opencode-hive(pass)bun run testinpackages/opencode-hivehas one unrelated pre-existing failure insrc/e2e/opencode-runtime-smoke.test.tsexpecting deprecatedhive_exec_startManual Validation
Prompt to test
Use this prompt with
hive-master(orswarm-orchestrator) to validate both non-terminal and terminal behavior:Expected manual outcomes
nextAction.done.hive_status().