GeezerVison is showing github.com — OpenAI cyber_policy refusals are classified as UnknownProvider instead of ContentPolicy · Issue #64843 · anomalyco/opencode
OpenAI cyber_policy refusals are classified as UnknownProvider instead of ContentPolicy #64843DescriptionDescription
OpenAI's cybersecurity safeguard rejects a turn with the error code cyber_policy, either as an HTTP 400 or as an error frame in the middle of a Responses stream. classifyProviderFailure does not know that code and the message does not match CONTENT_POLICY_TEXT, so the failure becomes UnknownProvider (provider.unknown) instead of ContentPolicy (provider.content-filter).
Clients that react to content-policy failures (for example by switching to another model) cannot tell this refusal apart from a transient unknown error, and the session retry policy treats it as retry-eligible even though retrying the same model gets the same refusal.
OpenCode version
2.3.2
Steps to reproduce
- Run a session on an OpenAI Responses model (seen with
gpt-6.1-sol) with a prompt that trips the cyber safeguard.
- The stream carries
{"type":"error","code":"cyber_policy","message":"This content was flagged for possible cybersecurity risk. ..."}.
- The session fails with
provider.unknown and message cyber_policy: This content was flagged for possible cybersecurity risk. ..., not provider.content-filter.
Operating System
Linux (sandboxed server, opencode serve --stdio) Activityopencodejr commented on Nov 19, 2026 Seen with a simulated model or a mock server, not a real provider; a maintainer should confirm.
Thanks for the precise report. I reproduced this on 2.3.2, using a local mock of the OpenAI Responses endpoint because I have no OpenAI credentials. The mock sends response.created and then an error frame with code: "cyber_policy".
opencode run --format json -m openai/gpt-5 reported the failure as provider.unknown and retried it about 10 times before failing with the same provider.unknown error, instead of provider.content-filter. The behaviour is the same on the latest dev (d33b578).
One detail: when I sent the same code as an HTTP 400, it was reported as provider.invalid-request and not retried. That is still not a content-filter error, but provider.unknown and the retry loop only showed up for the mid-stream error frame.
The script below reproduces it. Your PR #64844 addresses this.
Reproduction script (repro.sh)
#!/usr/bin/env bash
# Reproduces #64843: an OpenAI Responses stream `error` frame with code `cyber_policy`
# is classified as provider.unknown (and retried) instead of provider.content-filter.
# Needs bun and `opencode` on PATH (bun add -g @opencode/[email protected]).
# Set OC_DEV=/path/to/checkout to run the CLI from source instead.
set -euo pipefail
DIR=$(mktemp -d); cd "$DIR"
cat > mock.ts <<'TS'
const msg = "This content was flagged for possible cybersecurity risk. If this seems wrong, try rephrasing your request."
Bun.serve({ port: 4555, fetch(req) {
if (!new URL(req.url).pathname.endsWith("/responses")) return new Response("not found", { status: 404 })
const frames = [
{ type: "response.created", sequence_number: 0, response: { id: "resp_1", object: "response", status: "in_progress", model: "gpt-5", output: [] } },
{ type: "error", sequence_number: 1, code: "cyber_policy", message: msg, param: null },
]
return new Response(frames.map((f) => `event: ${f.type}\ndata: ${JSON.stringify(f)}\n\n`).join(""), { headers: { "content-type": "text/event-stream" } })
} })
TS
bun mock.ts & MOCK=$!; trap 'kill $MOCK' EXIT; sleep 1
mkdir proj && cd proj && git init -q
echo '{ "providers": { "openai": { "settings": { "baseURL": "http://127.0.0.1:4555/v1" } } } }' > opencode.jsonc
export OPENAI_API_KEY=sk-test
if [ -n "${OC_DEV:-}" ]; then
# From source, --standalone cannot spawn its child server, so start one with `serve`.
OC=(bun --conditions=browser --preload="$OC_DEV/packages/tui/node_modules/@opentui/solid/scripts/preload.js" "$OC_DEV/packages/cli/src/index.ts")
"${OC[@]}" serve --port 4778 > ../serve.log 2>&1 & SRV=$!; trap 'kill $MOCK $SRV' EXIT
until grep -q "server password" ../serve.log 2>/dev/null; do sleep 1; done
export OPENCODE_PASSWORD=$(awk '/server password/ {print $3}' ../serve.log)
TARGET=(--server http://127.0.0.1:4778)
else OC=(opencode); TARGET=(--standalone); fi
"${OC[@]}" --version
# Stop after the first error/retry event: on the affected version the run keeps retrying for ~90s.
timeout 120 "${OC[@]}" run "${TARGET[@]}" --format json -m openai/gpt-5 "hello" 2>&1 \
| grep -m1 -E '"type":"(retry|error)"' | grep -o '"error":{"type":"[^"]*"' || true
# Affected: "error":{"type":"provider.unknown" Expected: "error":{"type":"provider.content-filter"
Run it: bash repro.sh
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|