Skip to content

fix: _rstrip_last_assistant_message only strips trailing whitespace from the content — it does not remove the assistant message. - #8060

Open
wooyongbin3-cpu wants to merge 1 commit into
microsoft:mainfrom
wooyongbin3-cpu:pr-bot/fix-7768
Open

fix: _rstrip_last_assistant_message only strips trailing whitespace from the content — it does not remove the assistant message.#8060
wooyongbin3-cpu wants to merge 1 commit into
microsoft:mainfrom
wooyongbin3-cpu:pr-bot/fix-7768

Conversation

@wooyongbin3-cpu

Copy link
Copy Markdown

Auto-generated fix for #7768\n\n### What happened?

Describe the bug
_rstrip_last_assistant_message only strips trailing whitespace from the content — it does not remove the assistant message. So when the message history genuinely ends with a non-empty assistant message, it passes through unchanged and Anthropic rejects it.

Claude Recommend Fix

        from autogen_ext.models.anthropic import AnthropicChatCompletionClient

        class _AnthropicClient(AnthropicChatCompletionClient):
            # autogen-ext 0.7.x only whitespace-strips trailing assistant messages;
            # Anthropic API requires the conversation to end with a user message.
            def _rstrip_last_assistant_message(self, messages: Sequence[_LLMMessage]) -> Sequence[_LLMMessage]:
                msgs = list(messages)
       

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