anomalyco / anomalyco/opencode

compaction: automatic compaction can fail with provider invalid_prompt

Open
#47,939 1 comment 0 reactions 1 assignee View on GitHub

@kitlangton is already working on this.

Since Sep 8, 2026.

2.0
Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Summary

Automatic compaction can fail because OpenAI rejects the generated compaction prompt as potentially violating usage policy. The raw provider error interrupts session draining instead of recovering gracefully.

Environment

  • opencode version: 0.0.0-beta-19296
  • OS: Windows 10.0.26200.9168
  • Terminal: TERM=xterm-256color; terminal program unavailable
  • Shell: C:\WINDOWS\system32\cmd.exe
  • Install/channel: beta, reported as up to date
  • Active plugins: none found in global or project configuration

Reproduction

  1. Continue a sufficiently long session until automatic compaction runs.
  2. Allow OpenCode to compact the existing conversation automatically.
  3. Observe the session fail with a raw invalid_prompt provider error.

Reproduction is intermittent: one automatic compaction failed, while a later automatic compaction in the same session completed.

Expected Behavior

Automatic compaction should complete, retry safely, or surface a recoverable compaction-specific error without failing the session drain.

Actual Behavior

The automatic compaction record was marked failed with error type provider.invalid-request, and the server logged:

Failed to drain Session

The user-facing error was:

invalid_prompt: Invalid prompt: your prompt was flagged as potentially violating our usage policy. Please try again with a different prompt: https://platform.openai.com/docs/guides/reasoning#advice-on-prompting

Additional Context

  • The failure occurred during automatic compaction.
  • The failed record contained no summary or model metadata.
  • A later automatic compaction completed with OpenAI gpt-5.6-sol.
  • No prompt or conversation content is included here for privacy.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.