fix(opencode): surface content-filter finish reason as visible error (#31745)
Co-authored-by: Aiden Cline <aidenpcline@gmail.com>
This commit is contained in:
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user