remove OpenCode serve+attach workaround for stateless CLI#326
remove OpenCode serve+attach workaround for stateless CLI#326AdityaNair-jpg wants to merge 4 commits intoAgent-Field:mainfrom
Conversation
Performance
✓ No regressions detected |
Manual Testing Failed — CLI Interface MismatchTested locally against OpenCode v0.0.55 (latest release as of 2026-04-01). The provider builds commands using Reproductionfrom dotenv import load_dotenv
load_dotenv()
import asyncio
from agentfield.harness.providers.opencode import OpenCodeProvider
async def test():
p = OpenCodeProvider()
r = await p.execute('say hello', {'model': 'openai/gpt-4o'})
print('error:', r.is_error)
print('failure_type:', r.failure_type)
print('output:', (r.result or '')[:200])
print('error_msg:', (r.error_message or '')[:200])
asyncio.run(test())OutputDetails
The refactor itself is structurally clean, but the target CLI interface ( |
…AdityaNair-jpg/agentfield into refactor/opencode-stateless-cli
|
I'm really sorry, I trusted the original code's CLI interface without verifying against the actual OpenCode CLI. The original implementation used Fixed the CLI interface in both Python and TypeScript SDKs:
Verification:
|
Update: Manual test now passes after CLI fix ✓Re-tested against OpenCode v0.0.55 with the updated Unit tests: 9/9 passing. Required change: restore
|
|
The system now properly handles system_prompt option by prepending it to the user prompt since OpenCode has no native --system-prompt flag. Changes Made Python (opencode.py): TypeScript (opencode.ts): |
Summary
This PR refactors the OpenCode harness provider to use a simple, stateless CLI subprocess pattern. This change removes the previous "serve+attach" workaround which was required to bypass a "Session not found" bug in headless mode (upstream issue opencode#13851).
Key improvements include:
opencode runcalls, aligning with the pattern used by Gemini and Codex providers.opencode_serverfield fromHarnessConfigand simplified directory routing in the core runner.--dirproject isolation support.Testing
./scripts/test-all.shsdk/python/tests/test_harness_provider_opencode.pypass using new mocks.tests/debug_complex_json.pycorrectly reaches execution phase.opencode runwithout a temp subdirectory correctly writes to the targetproject_dir.Checklist
CHANGELOG.md(or this change does not warrant a changelog entry).Screenshots (if UI-related)
No UI changes; logic refactor only.
Closes #221
Related issues
Fixes #206
References #210, #220