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

Co-authored-by: Aiden Cline <aidenpcline@gmail.com>
This commit is contained in:
Kevin Dawkins
2026-06-11 08:41:11 -07:00
committed by GitHub
parent a1dee8b273
commit e2527db3c7
6 changed files with 110 additions and 0 deletions
+12
View File
@@ -1355,6 +1355,18 @@ export const layer = Layer.effect(
const finished = handle.message.finish && !["tool-calls", "unknown"].includes(handle.message.finish)
if (finished && !handle.message.error) {
// Surface any content-filter finish (e.g. Anthropic stop_reason:
// refusal) as an error. These turns may have produced no visible
// output at all — previously the session went idle silently — or
// partial text that was cut off by the provider's filter.
if (handle.message.finish === "content-filter") {
handle.message.error = new SessionV1.ContentFilterError({
message: "The response was blocked by the provider's content filter",
}).toObject()
yield* sessions.updateMessage(handle.message)
yield* events.publish(Session.Event.Error, { sessionID, error: handle.message.error })
return "break" as const
}
if (format.type === "json_schema") {
handle.message.error = new SessionV1.StructuredOutputError({
message: "Model did not produce structured output",