anomalyco / anomalyco/opencode
Automatic compaction drops JSON output format
@rekram1-node is already working on this.
Since Sep 15, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Description
Automatic compaction loses format: { type: "json_schema", ... }. The next model request no longer offers StructuredOutput, and a normal text completion returns with both info.structured and info.error undefined.
The format is omitted from both the compaction marker and its synthetic continuation. The prompt loop selects the latest user message's format, so it falls back to text mode.
There is also a related overflow-replay failure: copying a stored JSON format into updateMessage throws Expected OutputFormatJsonSchema because the stored value is a plain object.
Plugins
None required; reproduced using the native prompt test harness and local fake provider.
OpenCode version
1.18.29; affected source is unchanged on dev at e03db9bc6908f75c9334d8aa997deeaac81c0298.
Steps to reproduce
- Seed a completed conversation near the model's context limit.
- Submit a new JSON-schema prompt.
- Allow automatic compaction to summarize and continue.
- Have the local provider call
StructuredOutputwhen offered, otherwise return text. - Observe an undefined structured result with no error. The same request without compaction returns the structured result.
Native regression tests reproduce this without live model calls. The proposed fix carries the format through compaction and decodes persisted formats before republishing them.
Operating System
macOS, Bun 1.3.14.
Terminal
Headless test runner.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.