opencode-task-result-guard
v0.1.2
Published
OpenCode server plugin that recovers missing and incomplete subagent task handoffs.
Maintainers
Readme
opencode-task-result-guard
OpenCode server plugin that repairs missing or incomplete foreground Task handoffs before the parent agent sees them.
OpenCode can currently mark a child Task complete while returning an empty <task_result> when the child's terminal assistant message has no text. A separate race can let an auto-fallback plugin continue the child after the parent already received that empty result. Long-running critic agents can also compact and return a progress note instead of their required final report.
The guard runs at tool.execute.after and leaves normal Task output unchanged.
Behavior
- Reuses the newest non-synthetic child text when the terminal Task result is empty.
- Waits a bounded interval for a late report after
ContentFilterError. - Returns a visible
<task_error>with the sametask_idwhen no text can be recovered. - Optionally recognizes incomplete agents by name prefix and gives them one synthesis-only finalizer turn.
- Injects a hidden finalizer agent with all tools denied.
- Bounds repaired output while preserving its beginning and tail.
Install
opencode plugin opencode-task-result-guard --globalOr add it to global opencode.json:
{
"plugin": ["opencode-task-result-guard"]
}Restart OpenCode after installation.
Requires an OpenCode build with modern server plugin entrypoints (exports["./server"]). Tested against 0.0.0-beta-202607101924.
Options
Plugin options use an OpenCode plugin tuple:
{
"plugin": [
[
"opencode-task-result-guard",
{
"lateResultWaitMs": 180000,
"finalizeTimeoutMs": 180000,
"pollMs": 1000,
"maxBytes": 49152,
"finalizerAgent": "task-result-guard-finalizer",
"finalizerModel": "openai/gpt-5.4-mini",
"finalizerReasoningEffort": "high",
"finalizeAgentPrefixes": ["eye-"],
"finalMarker": "## Verdict"
}
]
]
}finalizerModel and finalizerReasoningEffort are optional. Without a model, the finalizer inherits the child session's model. Set finalizeAgentPrefixes to an empty array to disable semantic finalization while keeping empty-result recovery.
Set lateResultWaitMs to 0 to disable waiting for post-error fallback output.
Environment fallbacks are also supported:
OPENCODE_TASK_RESULT_WAIT_MSOPENCODE_TASK_FINALIZE_TIMEOUT_MSOPENCODE_TASK_RESULT_POLL_MSOPENCODE_TASK_RESULT_MAX_BYTESOPENCODE_TASK_FINALIZER_AGENTOPENCODE_TASK_FINALIZER_MODELOPENCODE_TASK_FINALIZER_REASONING_EFFORT
Tuple options take precedence over environment variables.
Limits
This covers synchronous foreground Task results. Background Task completion is injected as a synthetic parent message outside tool.execute.after and is not repaired by this plugin.
Semantic completeness is unknowable for arbitrary agents. By default, only agents whose names start with eye- are checked for a line equal to ## Verdict. Empty-result recovery applies to every agent.
The guard never exposes reasoning parts as a result. If recovery fails, it returns an explicit error and resumable task ID instead.
Relevant upstream reports include #24447, #27210, and #32132.
Development
bun install --frozen-lockfile
bun test
bun run build
npm run test:package
npm pack --dry-run --json --ignore-scripts