Skip to content

fix(provider): keep Claude prefill requests user-final#26477

Open
codeg-dev wants to merge 1 commit intoanomalyco:devfrom
codeg-dev:fix/claude-prefill-user-final
Open

fix(provider): keep Claude prefill requests user-final#26477
codeg-dev wants to merge 1 commit intoanomalyco:devfrom
codeg-dev:fix/claude-prefill-user-final

Conversation

@codeg-dev
Copy link
Copy Markdown

@codeg-dev codeg-dev commented May 9, 2026

Issue for this PR

Closes #13768

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

This fixes two ways a request can resolve to the wrong provider-facing shape:

  1. Claude Opus/Sonnet 4.6 and 4.7 can reject a request when the final model message is an assistant turn. The provider transform now removes trailing assistant turns for those Claude models. For Claude thinking requests, it also removes text-only trailing assistant turns while keeping trailing tool-call turns intact.
  2. Plugin-provided core agents may be keyed by display names with zero-width ordering prefixes, such as Atlas - Plan Executor. Agent.get() now also matches a normalized short alias, so --agent atlas resolves the displayed Atlas agent instead of falling back to the default agent.

The changes are in the provider transform and agent lookup choke points, so callers do not need to handle these cases separately.

How did you verify your code works?

  • bun test test/agent/agent.test.ts --timeout 30000 --test-name-pattern 'Agent.get resolves display-name agents by short alias|Agent.get returns undefined for non-existent agent'
  • bun test test/provider/transform.test.ts --timeout 30000
  • bun run typecheck
  • bun run build
  • Manual transform driver confirmed a Claude Opus 4.7 request with trailing assistant text is transformed to end with a user message.

Screenshots / recordings

Not applicable; this is provider/agent resolution behavior.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Authorship disclosure: prepared with AI assistance.

@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels May 9, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 9, 2026

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 9, 2026

The following comment was made by an LLM, it may be inaccurate:

Based on my search, I found 2 potentially related PRs (excluding the current PR #26477):

  1. PR fix: disable assistant prefill for Claude 4.6 models #14772 - fix: disable assistant prefill for Claude 4.6 models

  2. PR fix: Opus prefill rejection during tool-call loops with thinking enabled #22404 - fix: Opus prefill rejection during tool-call loops with thinking enabled

These PRs appear to be related to similar Claude provider prefill/transform logic, though they may address different edge cases or versions. You may want to review them to ensure there's no overlapping work.

@github-actions github-actions Bot removed needs:compliance This means the issue will auto-close after 2 hours. needs:issue labels May 9, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 9, 2026

Thanks for updating your PR! It now meets our contributing guidelines. 👍

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.

This model does not support assistant message prefill / Github Copilot with Opus 4.6

1 participant