Skip to content

Fix assistant-tailed requests and keep the tail cache breakpoint - #35

Open
olosegres wants to merge 2 commits into
dotCipher:mainfrom
olosegres:fix/request-tail-shape
Open

olosegres wants to merge 2 commits into
dotCipher:mainfrom
olosegres:fix/request-tail-shape

Conversation

@olosegres

Copy link
Copy Markdown
Contributor

Summary

  • End every Claude request on a user turn. The subscription endpoint rejects assistant-message prefill ("This model does not support assistant message prefill. The conversation must end with a user message."). Only opencode's exact Continue with your tasks. nudge was handled, so any other assistant-tailed request failed with a 400 — e.g. a resumed session whose last saved turn was the assistant's, or opencode's max-steps prefill. The nudge is still dropped; any other assistant tail now gets a minimal Continue. user turn appended, so the assistant content is kept.
  • Keep the tail cache_control breakpoint. opencode puts its prompt-prefix breakpoint on the tail message's last part, and the bridge stripped cache_control from every message text block, so text-tailed requests (plain user turns, compaction requests) never read the cached prefix (cache_read 0) — only tool-tailed requests did. Earlier text breakpoints are still stripped and none is added, so the four-breakpoint cap still holds.

This also fixes the max-steps prefill failure #26 is after; regression tests cover both its string and text-block shapes.

Test plan

  • npm test
  • npm run typecheck
  • With the plugin loaded in OpenCode, two plain text turns in one session: the first writes the prompt cache, the second reads it back (cache_read 0 before this change).

The subscription endpoint rejects assistant-message prefill ("does not
support assistant message prefill. The conversation must end with a user
message"). Only opencode's exact "Continue with your tasks." nudge was
handled, so any other assistant-tailed request - e.g. a resumed session
whose last saved turn was the assistant's - failed with a 400.

Drop the nudge as before, then append a minimal user turn after any
remaining assistant tail, keeping the assistant content.
opencode marks the tail message's last part with cache_control as the
prompt-prefix breakpoint. The bridge stripped cache_control from every
message text block, so a text-tailed request (a plain user turn, or a
compaction request) had no breakpoint left and never read the warm
prefix (cache_read 0); only tool-tailed requests were cached.

Strip earlier text breakpoints but keep the tail one. No breakpoint is
added, so the API's four-breakpoint cap still holds.
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