Skip to content

fix(openai): put the hybrid Responses breakpoint on OpenCode 2.3.2's developer system prompt - #51

Merged
cris005 merged 7 commits into
mainfrom
fix/responses-developer-system-prompt
Nov 19, 2026
Merged

cris005 merged 7 commits into
mainfrom
fix/responses-developer-system-prompt

Conversation

@cris005

@cris005 cris005 commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

OpenCode 2.3.2 moved the Responses system prompt out of instructions and into a leading developer message, because GPT-6.2 never caches instructions (anomalyco/opencode#64542, #64544). Merging this also releases 0.8.3. This PR keeps hybrid's 12h breakpoint at the end of that system prompt, including when an additional_tools item comes first.

The problem

On the Responses wire, hybrid put its 12h breakpoint on the first input item, whatever its role, because instructions is a plain string that can't carry one. With 2.3.2 that first item is now the system prompt itself, which happens to be the right spot. Two cases still went wrong:

  • Models that declare tools in place (capabilities.tools.updates includes "add"): OpenCode puts an additional_tools item before the system prompt. The first item then isn't a message, so hybrid placed no breakpoint and stripped any existing one. This was already broken before 2.3.2.
  • A leading developer message whose content has no text: nothing stepped past it to the next prefix message.
"input": [
  { "type": "additional_tools", "role": "developer", "tools": [...] },
  { "type": "message", "role": "developer", "content": "<system prompt>" },
  { "type": "message", "role": "user", "content": [...] }
]

The change

  • New responsesPrefixText (src/services/openai-responses-cache.ts): it skips leading additional_tools items, then returns the last input_text of the leading developer/system messages. When input doesn't start with such a message (older OpenCode, which sends instructions), it falls back to the old first-item rule, so pre-2.3.2 bodies are unchanged. firstInputItem is removed, since this was its only caller.
  • 1h, pings and the strip-then-mark rewrite are untouched. A breakpoint from an older first-user placement moves to the developer message.
  • Docs: the hybrid and 1h cells in docs/SUPPORTED_PROVIDERS.md and README.md now describe the developer-message shape.

Probe: OpenAI honours a breakpoint on a developer message

The code comments only covered user and system messages, so I checked developer messages live. I sent Responses requests through OpenRouter on openai/gpt-6-luna. The whole probe cost under $0.01.

Variant First request: write Input cost Next turn: cached
breakpoint on the developer input_text 3,645 $0.000910 (≈ $0.25/M, the 12h write rate) 3,636
breakpoint on the user input_text (control) 3,642 $0.000911 (12h rate) 3,642
no breakpoint 3,643 $0.000456 (≈ $0.125/M, the 30m rate) 3,637

OpenRouter doesn't pass through the ttl_12h_tokens split, so the 12h write is inferred from the doubled write price.

Worth checking

  • Unrelated CI fix (b30ca83). npm package tarball > contains exactly the ship set timed out on the first CI run: it built and packed the tarball inside the test, which took 5.02s against Bun's 5s default (0.9–2.7s on earlier runs). Packing now runs once in a beforeAll with a 60s timeout.
  • /responses/compact is still unmanaged. It doesn't match the /responses path check, same as before, so the plugin doesn't touch it.

Testing

  • Unit tests for responsesPrefixText: the developer prompt, additional_tools, walking back within the prefix run, a prefix run with no text, a mid-conversation developer message, and the pre-2.3.2 shape.
  • Profile tests for the 2.3.2 shape, and moving an old breakpoint onto the developer message.
  • The property oracle in openai.property.test.ts is updated to the new rule, and the arbitraries now generate additional_tools items. Run at FC_NUM_RUNS=5000.
  • A hook-level test in tests/middleware/request.test.ts for hybrid on the 2.3.2 shape.
  • bun run fmt:check, bun run lint, bun run typecheck and bun test pass (1297 tests).

@sonarqubecloud

Copy link
Copy Markdown

@cris005
cris005 merged commit 7b96a50 into main Nov 19, 2026
3 checks passed
@cris005
cris005 deleted the fix/responses-developer-system-prompt branch November 19, 2026 00:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant