Skip to content

fix(anthropic): update prefill regex for Claude 4.7+ and guard trailing tool_use (#7217) - #7246

Open
rrfunde wants to merge 2 commits into
livekit:mainfrom
rrfunde:fix/anthropic-prefill-claude-4-7
Open

fix(anthropic): update prefill regex for Claude 4.7+ and guard trailing tool_use (#7217)#7246
rrfunde wants to merge 2 commits into
livekit:mainfrom
rrfunde:fix/anthropic-prefill-claude-4-7

Conversation

@rrfunde

@rrfunde rrfunde commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Fixes #7217

@rrfunde
rrfunde requested a review from a team as a code owner September 12, 2026 11:12
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 12, 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 Completed 2026-09-12T12:04:38.314034Z d4d45de 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.

devin-ai-integration[bot]

This comment was marked as resolved.

@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: 8ae915784b

ℹ️ 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 on lines +148 to +151
for i, group in enumerate(groups):
# Trailing tool calls in the last group without outputs are unresolved/pending
if i == len(groups) - 1 and group.tool_calls and not group.tool_outputs:
continue

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Scope dangling tool-call preservation to Anthropic

When a context ends with an unresolved FunctionCall, this shared helper now preserves it for every provider, not only Anthropic. The OpenAI formatters in _provider_format/openai.py consume this helper and serialize the group as a final assistant tool_calls message without the required tool response, so retrying or falling back with an in-flight call can be rejected as invalid history. Preserve this group only when requested by the Anthropic formatter, or add provider-specific handling for the other consumers.

Useful? React with 👍 / 👎.

@rrfunde

rrfunde commented Sep 12, 2026

Copy link
Copy Markdown
Contributor Author

Addressed feedback: scoped unresolved tool call retention to Anthropic via allow_unresolved_tail=True in group_tool_calls, keeping the default behavior unchanged for all other providers.

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.

Anthropic plugin: hardcoded _NO_PREFILL_PATTERNS misses Claude 4.7/4.8/5, causing HTTP 400 "does not support assistant message prefill"

1 participant