Skip to content

Log refused optimizer calls in anthropic_optimizer_call - #387

Closed
Daniel (DanielValmir) wants to merge 1 commit into
microsoft:mainfrom
DanielValmir:pr/log-optimizer-refusals
Closed

Daniel (DanielValmir) wants to merge 1 commit into
microsoft:mainfrom
DanielValmir:pr/log-optimizer-refusals

Conversation

@DanielValmir

Copy link
Copy Markdown

A refused anthropic_optimizer_call arrives as HTTP 200 with stop_reason: "refusal" and no text. The mechanisms read the empty text as "no verdict" and take their LLM-free path, and no log line shows it. On Claude Sonnet 5 and later, safety classifiers can refuse requests (for example in the cyber category).

This change logs the refusal and its stop_details.category, as the max_tokens case already does. Behavior does not change.

Test: test_a_refusal_is_logged_not_silently_read_as_no_verdict in experiments/tests/test_optimizer_basis.py fails without the change and passes with it. The whole file passes (21 tests).

🤖 Generated with Claude Code

A refusal arrives as HTTP 200 with no text. The mechanisms read it as
"no verdict" and take their LLM-free path, and no log line shows it.
Log the refusal and its category, as the max_tokens case already does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@DanielValmir
Daniel (DanielValmir) deleted the pr/log-optimizer-refusals branch December 5, 2026 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant