Skip to content

fix(opencode): surface content-filter finish reason as visible error#31745

Merged
rekram1-node merged 2 commits into
anomalyco:devfrom
kkdawkins:fix/content-filter-silent-stop
Jun 11, 2026
Merged

fix(opencode): surface content-filter finish reason as visible error#31745
rekram1-node merged 2 commits into
anomalyco:devfrom
kkdawkins:fix/content-filter-silent-stop

Conversation

@kkdawkins

@kkdawkins kkdawkins commented Jun 10, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #31744

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

When a provider ends a turn with the content-filter finish reason (e.g. Anthropic stop_reason: refusal), no error was attached to the assistant message, so the prompt loop exited and the session went idle. If the turn produced no visible output, nothing rendered at all — it looked like opencode just stopped.

This adds a ContentFilterError to the assistant error union and attaches it in the prompt loop when a finished turn has finish === "content-filter" and no existing error, alongside publishing session.error. This mirrors the existing StructuredOutputError handling in the same block. The TUI and web app already render any non-aborted message.error, so no client changes were needed.

How did you verify your code works?

  • Traced the failing path: refusal -> content-filter in packages/llm/src/protocols/anthropic-messages.ts, processor records the finish with no error, loop previously broke silently at the finish check in prompt.ts
  • bun typecheck passes across all 23 packages (pre-push hook)
  • Regenerated the JS SDK via ./packages/sdk/js/script/build.ts

To confirm: force a turn to finish with content-filter — the assistant message now carries ContentFilterError and the UI shows the error box instead of nothing.

Screenshots / recordings

N/A (renders through the existing error box UI)

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR
@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Jun 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

@rekram1-node

Copy link
Copy Markdown
Collaborator

thank u!

@rekram1-node rekram1-node merged commit e2527db into anomalyco:dev Jun 11, 2026
8 checks passed
isaacfinnegan pushed a commit to isaacfinnegan/whispercode that referenced this pull request Jun 15, 2026
leduyphuc1702 pushed a commit to leduyphuc1702/opencode-workflow that referenced this pull request Jun 16, 2026
Inherits upstream anomalyco#31745, adapted to fork's structure: ContentFilterError added to
session/message-v2 (fork's MessageV2 errors, not upstream core/v1/session) + AssistantErrorSchema,
handler in prompt.ts finish region, SDK types.gen.ts + openapi.json updated.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
davidgut1982 pushed a commit to davidgut1982/opencode that referenced this pull request Jun 19, 2026
markjaquith pushed a commit to markjaquith/opencode that referenced this pull request Jun 23, 2026
BenGu3 pushed a commit to BenGu3/opencode that referenced this pull request Jun 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants