@omsfuk/opencode-empty-content-fix
v0.1.0
Published
Prevents empty message content from reaching OpenAI-compatible gateways, eliminating the '[System: Empty message content sanitised to satisfy protocol]' placeholder
Downloads
103
Maintainers
Readme
opencode-empty-content-fix
opencode plugin that prevents [System: Empty message content sanitised to satisfy protocol]
from appearing in conversations when using an OpenAI-compatible gateway (LiteLLM,
Open WebUI, token-plan gateways, ...).
Why it happens
When an assistant turn contains only tool calls, the AI SDK serializes it with
content: "" on the wire. OpenAI-compatible gateways sanitize empty content by
replacing it with the placeholder text above, then echo it back into the
conversation history. opencode's own empty-content filter only covers
@ai-sdk/anthropic and @ai-sdk/amazon-bedrock, so proxy-routed providers are
affected.
What this plugin does
experimental.chat.messages.transform— before every request:- strips placeholder text parts from the outgoing history, and
- injects a non-empty text part into assistant turns that carry tool calls
but no text, so the wire
contentis never empty and the gateway has nothing to sanitize. - reasoning parts are never touched (they may carry positionally sensitive provider signatures).
experimental.chat.system.transform— drops empty/whitespace-only system prompt entries.
Already-polluted history stays in the database and is still rendered by the UI; the plugin stops new placeholders from being generated. Start a new session for a clean transcript.
Usage
Enable the plugin in your opencode config (~/.config/opencode/opencode.jsonc
for global):
{
"plugin": [
"@omsfuk/opencode-empty-content-fix"
]
}opencode installs npm plugins on demand. You can also use a local path or
file:// URL for development. Restart opencode after changing the config.
Development
bun install
bun run typecheck
bun test