Skip to content

v4.0.2 - Fix Compaction & Agent Creation

Latest

Choose a tag to compare

@numman-ali numman-ali released this 27 Nov 13:57

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_output items 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 create command was failing with "Invalid JSON response" because we were returning SSE streams instead of JSON for generateText() 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-latest model support: Added to model map, normalizes to gpt-5.1.

Technical Details

  • Compaction fix: OpenCode sends item_reference with fc_* IDs for function calls. We filter these for stateless mode, but v4.0.1 then removed ALL tool items. Now we only remove orphaned function_call_output items (where no matching function_call exists).
  • Agent creation fix: We were forcing stream: true for all requests and returning SSE for all responses. Now we capture original stream value 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.lock

Full Changelog: v4.0.1...v4.0.2