Bugfix Release
Fixes compaction context loss, agent creation, and SSE/JSON response handling.
Fixed
- Compaction losing context: v4.0.1 was too aggressive in filtering tool calls - it removed ALL
function_call/function_call_outputitems when tools weren't present. Now only orphaned outputs (without matching calls) are filtered, preserving matched pairs for compaction context. - Agent creation failing: The
/agent createcommand was failing with "Invalid JSON response" because we were returning SSE streams instead of JSON forgenerateText()requests. - SSE/JSON response handling: Properly detect original request intent -
streamText()requests get SSE passthrough,generateText()requests get SSE→JSON conversion.
Added
gpt-5.1-chat-latestmodel support: Added to model map, normalizes togpt-5.1.
Technical Details
- Compaction fix: OpenCode sends
item_referencewithfc_*IDs for function calls. We filter these for stateless mode, but v4.0.1 then removed ALL tool items. Now we only remove orphanedfunction_call_outputitems (where no matchingfunction_callexists). - Agent creation fix: We were forcing
stream: truefor all requests and returning SSE for all responses. Now we capture originalstreamvalue before transformation and convert SSE→JSON only when original request wasn't streaming. - The Codex API always receives
stream: true(required), but response handling is based on original intent.
Upgrade
Update your opencode.json:
{
"plugin": ["[email protected]"]
}If stuck on an old version, clear the cache:
rm -rf ~/.cache/opencode/node_modules ~/.cache/opencode/bun.lockFull Changelog: v4.0.1...v4.0.2