Skip to content

v1.10.3: fix declined requests shown as an answer; say Claude declined - #14

Merged
gitluis merged 3 commits into
masterfrom
fix-ai-refusals
Nov 2, 2026
Merged

gitluis merged 3 commits into
masterfrom
fix-ai-refusals

Conversation

@gitluis

@gitluis gitluis commented Oct 26, 2026 •

Copy link
Copy Markdown
Owner

Base: master. #13 merged on 2026-10-26 and GitHub retargeted this PR. Merge order: this (v1.10.3) → #15 (v1.10.4) → #10 (v1.11.0), per Luis on 2026-10-26.

Summary

When Claude declines a question, the AI tab now says so instead of showing "(no response)" as if it were the answer. Found while reviewing #12; the bug was already on master.

Cause

The API's safety classifiers can decline a request. That comes back as a normal HTTP 200 with stop_reason: "refusal", an empty content and a stop_details object (category, explanation). It is not an error, so FinLens's error handling never saw it:

  • the AI tab rendered the placeholder "(no response)" as the answer;
  • it saved that to history as if it were an answer;
  • if the response held any partial text, the tab showed it as the answer. The API docs say to treat partial output from a refusal as incomplete and discard it;
  • the AI Eval counted a declined run as answered.

What changed

  • js/views-ai.js
    • send() returns refusal: { category, explanation } from stop_details for a declined request, otherwise null. Its text is the no-text placeholder, so partial text is dropped.
    • The AI tab shows aiRefusalHtml(): "Claude declined to answer this question", the explanation when there is one (escaped, and shown rather than parsed, as the docs advise), and a suggestion to ask a different way. Nothing goes to history or the copy buffer.
  • js/views-eval.js
    • A declined run is counted, not scored: the Calls row reports "N declined", like failed calls, and it is left out of the figures and the token averages. Each run stores its refusal.
    • The v1.10.0 run had no refusals, so it re-scores unchanged.
  • v1.10.3 in CHANGELOG, index.html, README and views-settings.js. CLAUDE.md §13 (refusals, raw-mode result) and §21 (declined runs).

Not changed: the request, the summary and how answers are scored, so this needs no eval re-run. No automatic retry on another model either: the API's server-side fallback is an opt-in beta (fallbacks + a beta header), and can be a separate change if you want it.

How it was tested

Headless Chromium, mocked API, on dbcc911 (#12 + #13 + this change, including both eval re-runs). The mocked refusal has the shape the API docs show.

Not verified: a real refusal. Finance questions are unlikely to trigger one, so this relies on the documented response shape.

Please check before merging

  • The message reads well to you. To see it without a real refusal, run this in DevTools on the AI tab:
    $('#aiResponse').innerHTML = aiRefusalHtml({ explanation: 'Example reason.' })
  • You're fine with no automatic retry on another model.

Source: Refusals and fallback



Generated by Claude Code

When the API's safety classifiers decline a request, the response is a
normal HTTP 200 with stop_reason "refusal" and no text. The AI tab
showed "(no response)" as the answer and saved it to history; the eval
counted it as an answered run. The bug was already on master.

- send() returns refusal ({ category, explanation } from stop_details,
  or null) and drops any partial text, as the API docs advise
- the AI tab shows aiRefusalHtml(): Claude declined, plus the escaped
  explanation when there is one; nothing goes to history or the copy
  buffer
- AI Eval counts declined runs in the Calls row, leaves them out of
  scoring and token averages, and stores each run's refusal
- v1.10.3; CLAUDE.md §13 and §21

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QiRz5pTW83oqNbk2NC7yMR
Base automatically changed from fix-ai-summary-date-range to master October 26, 2026 13:10

@gitluis gitluis left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fully reviewed. PR is approved.

@gitluis
gitluis merged commit 400aff9 into master Nov 2, 2026
@gitluis
gitluis deleted the fix-ai-refusals branch November 2, 2026 03:43
gitluis pushed a commit that referenced this pull request Nov 2, 2026
…ettings-database-tab

Carries master's v1.10.3-v1.10.5 up the stack: declined answers (#14),
literal single "~" (#15) and the Import Logs race fix (#18), with
clarity-insights' port of #14 to the rebuilt AI tab.

One conflict: CLAUDE.md's "Last updated" line. Kept this branch's
line and added the v1.10.3-v1.10.5 history. The CHANGELOG merged cleanly.
Versions stay 1.17.0. renderImportLog() keeps #18's guards.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013Z8iBXzUjiQbYziDZ8CZft
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.

2 participants