Skip to content

What a declined request added goes to later requests as a note naming the refusal - #361

Merged
lydakis merged 4 commits into
mainfrom
claude/project-thread-filai4
Oct 29, 2026
Merged

lydakis merged 4 commits into
mainfrom
claude/project-thread-filai4

Conversation

@lydakis

@lydakis lydakis commented Oct 29, 2026

Copy link
Copy Markdown
Owner

What

Follow-up to #349. When a turn still ends with provider_refusal, because the bot has no fallback or the fallback declined too, the part of the turn that the declined request added becomes a short note. Later requests see the note in its place. Anthropic says the turn that set off a refusal must be removed or rephrased before going on; otherwise the refusals continue. With this change the bot can carry on, and the model knows something was left out and why.

  • What is replaced: everything the declined request added since the model last answered. That is the prompt when it was the turn's first request, or else the latest tool results plus any steer. Earlier rounds of the turn, which the model already answered, stay as they are.
  • Notes: a tool result keeps its call id and reads [This tool result is left out: the provider's safety classifier declined the request that carried it (category: cyber).]. A message reads [A message here is left out: ...], and any further message reads [Another message here is left out, for the same reason.]. Shorter wordings are used for items too small for these.
  • Same size: each note is padded with spaces to the byte length of the item it replaces. Context byte accounting, the precomputed body length, and everything before the note stay unchanged, so no thinking binding or earlier cache prefix is touched.
  • Originals kept: the replaced items go into a new declined(node, item) table (schema 61). Turn listings still show the person's prompt, and an idempotent retry of the same request id still matches it. Deleting a bot deletes those rows too.
  • Event: turn_finished for a refused turn carries left_out, the number of items replaced.

Only the typed provider_refusal code triggers this, and nothing matches message text.

Tests

  • Rust: note wording for each size tier; call_id and tool_use_id kept; padding to the exact length; None when nothing fits.
  • Runtime (synthetic Anthropic endpoint): a refused first request leaves a note in place of the prompt, and the next turn's request carries it. A request refused on a tool result leaves a tool-result note that keeps its call. turns still shows the original prompt, and an idempotent retry of the refused request id answers with the same turn.

Not tested live: a real classifier refusal was not reproduced.


Generated by Claude Code

… the refusal

When a turn ends with `provider_refusal` (its fallback, if any, declined
too), what the declined request added since the model last answered
becomes a note in its place, as Anthropic says to remove it before going
on: the prompt, when it was the turn's first request, or the latest tool
results and any steer. A tool result keeps its call with
"[This tool result is left out: ...]"; a message becomes
"[A message here is left out: ...]", both naming the category.

Each note is padded to the size of the item it replaces, so context byte
accounting is unchanged, and nothing before it changes, so no thinking
binding or prompt cache is touched. The originals are kept in a new
`declined` table (schema 61): turn listings show the person's prompt and an
idempotent retry still matches it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013jkdGCoLcHQMmGw188SP8o
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-29T07:05:28.456202Z f2d555c New commits
🔒 Security Review ✅ Completed 2026-10-29T07:10:04.417877Z f2d555c New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d52c00fe04

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/store/db.rs Resolved
A fork taken while the request was out shares the prompt, and one taken
after tool results shares those: replacing them in place changed the
fork's history too. The walk now stops at the first node another bot
reaches (a head, fork point or saved start, or a child off this branch).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013jkdGCoLcHQMmGw188SP8o
A fork's fork point is on its own head's branch, so its head or a child
off this branch already shows it; bots.closed has no index.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013jkdGCoLcHQMmGw188SP8o

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9f048e9bd3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/store/db.rs Resolved
history_items, history_read, history_search and result_lines read the
original from declined; only the model's context carries the notes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013jkdGCoLcHQMmGw188SP8o
@lydakis
lydakis merged commit 1729948 into main Oct 29, 2026
5 checks passed
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