Skip to content

fix: trim trailing whitespaces for anthropic and bedrock anthropic provider - #3496

Merged
akshaydeo merged 1 commit into
devfrom
05-14-fix_trim_trailing_whitespaces_for_anthropic_and_bedrock_anthropic_provider
May 14, 2026
Merged

fix: trim trailing whitespaces for anthropic and bedrock anthropic provider#3496
akshaydeo merged 1 commit into
devfrom
05-14-fix_trim_trailing_whitespaces_for_anthropic_and_bedrock_anthropic_provider

Conversation

@sammaji

@sammaji sammaji commented May 14, 2026

Copy link
Copy Markdown
Member

Summary

Trailing whitespace (spaces, newlines, carriage returns, tabs) in the last assistant message is stripped before sending requests to Anthropic and Bedrock (Anthropic models). This prevents API errors that can occur when assistant prefill messages end with whitespace, which Anthropic's API rejects.

Changes

  • For the Anthropic provider, all text content blocks in the final assistant message are right-trimmed of whitespace before the request is sent, applied in both chat.go and responses.go.
  • For the Bedrock provider, the same trimming is applied to text blocks in the final assistant message, but only when the target model is an Anthropic model (since prefill is an Anthropic-specific concept), applied in both chat.go and responses.go.

Type of change

  • Bug fix
  • Feature
  • Refactor
  • Documentation
  • Chore/CI

Affected areas

  • Core (Go)
  • Transports (HTTP)
  • Providers/Integrations
  • Plugins
  • UI (React)
  • Docs

How to test

Send a chat completion request where the last message has role: assistant and its content ends with trailing whitespace or newlines.

chat completions

curl --location 'http://localhost:8080/v1/chat/completions' \
--header 'Content-Type: application/json' \
--data '{
    // "model": "anthropic/claude-haiku-4-5-20251001",
    // "model": "anthropic/claude-opus-4-1-20250805",
    // "model": "anthropic/claude-opus-4-20250514",
    // "model": "anthropic/claude-opus-4-5-20251101",
    // "model": "anthropic/claude-opus-4-6",
    // "model": "anthropic/claude-opus-4-7",
    // "model": "anthropic/claude-sonnet-4-20250514",
    // "model": "anthropic/claude-sonnet-4-5-20250929",
    // "model": "anthropic/claude-sonnet-4-6",
    // "model": "bedrock/us.anthropic.claude-3-haiku-20240307-v1:0",
    // "model": "bedrock/us.anthropic.claude-haiku-4-5-20251001-v1:0",
    // "model": "bedrock/us.anthropic.claude-opus-4-1-20250805-v1:0",
    // "model": "bedrock/us.anthropic.claude-opus-4-5-20251101-v1:0",
    // "model": "bedrock/us.anthropic.claude-opus-4-6-v1",
    // "model": "bedrock/us.anthropic.claude-opus-4-7",
    // "model": "bedrock/us.anthropic.claude-sonnet-4-20250514-v1:0",
    // "model": "bedrock/us.anthropic.claude-sonnet-4-5-20250929-v1:0",
    "model": "bedrock/us.anthropic.claude-sonnet-4-6",
    "messages": [
        {
            "role": "user",
            "content": "Hello"
        },
        {
            "role": "assistant",
            "content": "Hello " // trailing whitespace
        }
    ]
}'

anthropic integration (v1/messages)

curl --location 'http://localhost:8080/anthropic/v1/messages' \
--header 'Content-Type: application/json' \
--data '{
    // "model": "anthropic/claude-haiku-4-5-20251001",
    // "model": "anthropic/claude-opus-4-1-20250805",
    // "model": "anthropic/claude-opus-4-20250514",
    // "model": "anthropic/claude-opus-4-5-20251101",
    // "model": "anthropic/claude-opus-4-6",
    // "model": "anthropic/claude-opus-4-7",
    // "model": "anthropic/claude-sonnet-4-20250514",
    // "model": "anthropic/claude-sonnet-4-5-20250929",
    // "model": "anthropic/claude-sonnet-4-6",
    // "model": "bedrock/us.anthropic.claude-3-haiku-20240307-v1:0",
    // "model": "bedrock/us.anthropic.claude-haiku-4-5-20251001-v1:0",
    // "model": "bedrock/us.anthropic.claude-opus-4-1-20250805-v1:0",
    // "model": "bedrock/us.anthropic.claude-opus-4-5-20251101-v1:0",
    // "model": "bedrock/us.anthropic.claude-opus-4-6-v1",
    // "model": "bedrock/us.anthropic.claude-opus-4-7",
    // "model": "bedrock/us.anthropic.claude-sonnet-4-20250514-v1:0",
    // "model": "bedrock/us.anthropic.claude-sonnet-4-5-20250929-v1:0",
    "model": "bedrock/us.anthropic.claude-sonnet-4-6",
    "messages": [
        {
            "role": "user",
            "content": "Hello"
        },
        {
            "role": "assistant",
            "content": "Hey "
    ]
}'
"messages": [
        {
            "role": "user",
            "content": "Hello"
        },
        {
            "role": "assistant",
            "content": [
                {
                    "type": "text",
                    "text": "Hey "
                }
            ]
        }
    ]

Breaking changes

  • Yes
  • No

Related issues

Security considerations

No security implications. This change only modifies outbound message content formatting before it reaches the provider API.

Checklist

  • I read docs/contributing/README.md and followed the guidelines
  • I added/updated tests where appropriate
  • I updated documentation where needed
  • I verified builds succeed (Go and UI)
  • I verified the CI pipeline passes locally if applicable

@coderabbitai

coderabbitai Bot commented May 14, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Trim trailing right-side whitespace (spaces, newlines, tabs, carriage returns) from the last assistant message's text ContentBlock in Anthropic and Bedrock request/conversion paths across four provider modules.

Changes

Trailing Whitespace Normalization for Assistant Messages

Layer / File(s) Summary
Anthropic chat request trailing whitespace trimming
core/providers/anthropic/chat.go
ToAnthropicChatRequest trims trailing whitespace from the final assistant message's last text ContentBlock before calling stripUnsupportedAnthropicFields.
Anthropic message conversion trailing whitespace trimming
core/providers/anthropic/responses.go
ConvertBifrostMessagesToAnthropicMessages (request mode) scans backward through the last assistant message's ContentBlocks and right-trims the first non-nil Text block it finds; a formatting-only brace placement was also adjusted.
Bedrock Anthropic-model trimming in chat request
core/providers/bedrock/chat.go
Adds strings import and Anthropic-only post-processing that locates the final assistant message in bedrockReq.Messages, iterates content blocks backward, and applies strings.TrimRight to the first non-nil Text block.
Bedrock Anthropic-model trimming in response conversion
core/providers/bedrock/responses.go
ToBedrockResponsesRequest conditionally right-trims trailing whitespace from the last assistant message's content blocks when the target model is an Anthropic model, before continuing request construction.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

I hop through code on nimble paws,
Trimming tails of spaces, line-end gauze.
Four files neat, no trailing fluff—
Messages tidy, snips were not rough.
A rabbit cheers: clean text is enough. 🐇✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: trimming trailing whitespaces for Anthropic and Bedrock Anthropic providers.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The PR description is comprehensive and follows the required template with all essential sections completed and properly filled out.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 05-14-fix_trim_trailing_whitespaces_for_anthropic_and_bedrock_anthropic_provider

Comment @coderabbitai help to get the list of available commands and usage tips.

sammaji commented May 14, 2026

Copy link
Copy Markdown
Member Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@sammaji
sammaji force-pushed the 05-14-fix_trim_trailing_whitespaces_for_anthropic_and_bedrock_anthropic_provider branch 2 times, most recently from 4ae07e7 to d463298 Compare May 14, 2026 12:07
@sammaji
sammaji marked this pull request as ready for review May 14, 2026 12:36
@greptile-apps

greptile-apps Bot commented May 14, 2026

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

Safe to merge — the change is narrowly scoped to outbound request formatting and cannot affect response handling or other providers.

All four modified sites use a backward-iterating loop with an early break, so only the genuinely trailing text block is trimmed; mid-message whitespace is untouched. The Bedrock path is correctly guarded by IsAnthropicModel, the Responses path is guarded by isRequestMessage, and the Bedrock responses path is guarded by bifrostReq.Input != nil. No existing logic is restructured — this is a pure, additive trim step inserted at the end of each conversion function.

No files require special attention.

Important Files Changed

Filename Overview
core/providers/anthropic/chat.go Adds targeted whitespace trimming of the last text block in the final assistant message before sending to Anthropic API; correctly uses backward iteration with break to touch only the trailing block.
core/providers/anthropic/responses.go Same whitespace-trim logic as chat.go, gated on isRequestMessage so response messages are left untouched; also fixes missing newline at end of file.
core/providers/bedrock/chat.go Adds strings import and applies the same trailing-whitespace trim for Bedrock, correctly scoped to Anthropic models via schemas.IsAnthropicModel.
core/providers/bedrock/responses.go Mirrors the chat.go fix for the Responses API path; trimming is correctly placed inside the bifrostReq.Input != nil guard where messages are available.

Reviews (3): Last reviewed commit: "fix: trim trailing whitespaces for anthr..." | Re-trigger Greptile

Comment thread core/providers/anthropic/chat.go
Comment thread core/providers/anthropic/responses.go
Comment thread core/providers/bedrock/chat.go
Comment thread core/providers/bedrock/responses.go
coderabbitai[bot]
coderabbitai Bot previously approved these changes May 14, 2026
@sammaji
sammaji force-pushed the 05-14-fix_trim_trailing_whitespaces_for_anthropic_and_bedrock_anthropic_provider branch 2 times, most recently from c531a7e to d3d95a6 Compare May 14, 2026 12:47

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@core/providers/bedrock/chat.go`:
- Around line 46-57: The final assistant message trimming only trims the first
text block found from the end (the loop breaks), leaving earlier blocks with
trailing whitespace; in the Anthropic-only branch (check using
schemas.IsAnthropicModel and BedrockMessageRoleAssistant) iterate over all
entries in bedrockReq.Messages[lastMsgIndex].Content and for each block with a
non-nil Text field set bedrockReq.Messages[lastMsgIndex].Content[i].Text to
schemas.Ptr(strings.TrimRight(*blocks[i].Text, " \n\r\t")) instead of breaking
after the first trim so every text block in that final assistant message is
trimmed.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7b4705a7-6f1b-4972-a841-9a2a4b8e3f8d

📥 Commits

Reviewing files that changed from the base of the PR and between d463298 and c531a7e.

📒 Files selected for processing (4)
  • core/providers/anthropic/chat.go
  • core/providers/anthropic/responses.go
  • core/providers/bedrock/chat.go
  • core/providers/bedrock/responses.go
🚧 Files skipped from review as they are similar to previous changes (3)
  • core/providers/anthropic/chat.go
  • core/providers/anthropic/responses.go
  • core/providers/bedrock/responses.go

Comment thread core/providers/bedrock/chat.go
@akshaydeo
akshaydeo requested a review from a team as a code owner May 14, 2026 12:51
@sammaji
sammaji force-pushed the 05-14-fix_trim_trailing_whitespaces_for_anthropic_and_bedrock_anthropic_provider branch from d3d95a6 to df07242 Compare May 14, 2026 12:53

akshaydeo commented May 14, 2026

Copy link
Copy Markdown
Contributor

Merge activity

  • May 14, 2:32 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • May 14, 2:33 PM UTC: @akshaydeo merged this pull request with Graphite.

@akshaydeo
akshaydeo merged commit b6e317d into dev May 14, 2026
16 checks passed
@akshaydeo
akshaydeo deleted the 05-14-fix_trim_trailing_whitespaces_for_anthropic_and_bedrock_anthropic_provider branch May 14, 2026 14:33
akshaydeo pushed a commit that referenced this pull request May 15, 2026
…ovider (#3496)

## Summary

Trailing whitespace (spaces, newlines, carriage returns, tabs) in the last assistant message is stripped before sending requests to Anthropic and Bedrock (Anthropic models). This prevents API errors that can occur when assistant prefill messages end with whitespace, which Anthropic's API rejects.

## Changes

- For the Anthropic provider, all text content blocks in the final assistant message are right-trimmed of whitespace before the request is sent, applied in both `chat.go` and `responses.go`.
- For the Bedrock provider, the same trimming is applied to text blocks in the final assistant message, but only when the target model is an Anthropic model (since prefill is an Anthropic-specific concept), applied in both `chat.go` and `responses.go`.

## Type of change

- [x] Bug fix
- [ ] Feature
- [ ] Refactor
- [ ] Documentation
- [ ] Chore/CI

## Affected areas

- [x] Core (Go)
- [ ] Transports (HTTP)
- [x] Providers/Integrations
- [ ] Plugins
- [ ] UI (React)
- [ ] Docs

## How to test

Send a chat completion request where the last message has `role: assistant` and its content ends with trailing whitespace or newlines.

### chat completions

```
curl --location 'http://localhost:8080/v1/chat/completions' \
--header 'Content-Type: application/json' \
--data '{
    // "model": "anthropic/claude-haiku-4-5-20251001",
    // "model": "anthropic/claude-opus-4-1-20250805",
    // "model": "anthropic/claude-opus-4-20250514",
    // "model": "anthropic/claude-opus-4-5-20251101",
    // "model": "anthropic/claude-opus-4-6",
    // "model": "anthropic/claude-opus-4-7",
    // "model": "anthropic/claude-sonnet-4-20250514",
    // "model": "anthropic/claude-sonnet-4-5-20250929",
    // "model": "anthropic/claude-sonnet-4-6",
    // "model": "bedrock/us.anthropic.claude-3-haiku-20240307-v1:0",
    // "model": "bedrock/us.anthropic.claude-haiku-4-5-20251001-v1:0",
    // "model": "bedrock/us.anthropic.claude-opus-4-1-20250805-v1:0",
    // "model": "bedrock/us.anthropic.claude-opus-4-5-20251101-v1:0",
    // "model": "bedrock/us.anthropic.claude-opus-4-6-v1",
    // "model": "bedrock/us.anthropic.claude-opus-4-7",
    // "model": "bedrock/us.anthropic.claude-sonnet-4-20250514-v1:0",
    // "model": "bedrock/us.anthropic.claude-sonnet-4-5-20250929-v1:0",
    "model": "bedrock/us.anthropic.claude-sonnet-4-6",
    "messages": [
        {
            "role": "user",
            "content": "Hello"
        },
        {
            "role": "assistant",
            "content": "Hello " // trailing whitespace
        }
    ]
}'
```

### anthropic integration (v1/messages)

```
curl --location 'http://localhost:8080/anthropic/v1/messages' \
--header 'Content-Type: application/json' \
--data '{
    // "model": "anthropic/claude-haiku-4-5-20251001",
    // "model": "anthropic/claude-opus-4-1-20250805",
    // "model": "anthropic/claude-opus-4-20250514",
    // "model": "anthropic/claude-opus-4-5-20251101",
    // "model": "anthropic/claude-opus-4-6",
    // "model": "anthropic/claude-opus-4-7",
    // "model": "anthropic/claude-sonnet-4-20250514",
    // "model": "anthropic/claude-sonnet-4-5-20250929",
    // "model": "anthropic/claude-sonnet-4-6",
    // "model": "bedrock/us.anthropic.claude-3-haiku-20240307-v1:0",
    // "model": "bedrock/us.anthropic.claude-haiku-4-5-20251001-v1:0",
    // "model": "bedrock/us.anthropic.claude-opus-4-1-20250805-v1:0",
    // "model": "bedrock/us.anthropic.claude-opus-4-5-20251101-v1:0",
    // "model": "bedrock/us.anthropic.claude-opus-4-6-v1",
    // "model": "bedrock/us.anthropic.claude-opus-4-7",
    // "model": "bedrock/us.anthropic.claude-sonnet-4-20250514-v1:0",
    // "model": "bedrock/us.anthropic.claude-sonnet-4-5-20250929-v1:0",
    "model": "bedrock/us.anthropic.claude-sonnet-4-6",
    "messages": [
        {
            "role": "user",
            "content": "Hello"
        },
        {
            "role": "assistant",
            "content": "Hey "
    ]
}'
```

```
"messages": [
        {
            "role": "user",
            "content": "Hello"
        },
        {
            "role": "assistant",
            "content": [
                {
                    "type": "text",
                    "text": "Hey "
                }
            ]
        }
    ]
```

## Breaking changes

- [ ] Yes
- [x] No

## Related issues

## Security considerations

No security implications. This change only modifies outbound message content formatting before it reaches the provider API.

## Checklist

- [x] I read `docs/contributing/README.md` and followed the guidelines
- [x] I added/updated tests where appropriate
- [x] I updated documentation where needed
- [x] I verified builds succeed (Go and UI)
- [x] I verified the CI pipeline passes locally if applicable
akshaydeo pushed a commit that referenced this pull request May 15, 2026
…ovider (#3496)

## Summary

Trailing whitespace (spaces, newlines, carriage returns, tabs) in the last assistant message is stripped before sending requests to Anthropic and Bedrock (Anthropic models). This prevents API errors that can occur when assistant prefill messages end with whitespace, which Anthropic's API rejects.

## Changes

- For the Anthropic provider, all text content blocks in the final assistant message are right-trimmed of whitespace before the request is sent, applied in both `chat.go` and `responses.go`.
- For the Bedrock provider, the same trimming is applied to text blocks in the final assistant message, but only when the target model is an Anthropic model (since prefill is an Anthropic-specific concept), applied in both `chat.go` and `responses.go`.

## Type of change

- [x] Bug fix
- [ ] Feature
- [ ] Refactor
- [ ] Documentation
- [ ] Chore/CI

## Affected areas

- [x] Core (Go)
- [ ] Transports (HTTP)
- [x] Providers/Integrations
- [ ] Plugins
- [ ] UI (React)
- [ ] Docs

## How to test

Send a chat completion request where the last message has `role: assistant` and its content ends with trailing whitespace or newlines.

### chat completions

```
curl --location 'http://localhost:8080/v1/chat/completions' \
--header 'Content-Type: application/json' \
--data '{
    // "model": "anthropic/claude-haiku-4-5-20251001",
    // "model": "anthropic/claude-opus-4-1-20250805",
    // "model": "anthropic/claude-opus-4-20250514",
    // "model": "anthropic/claude-opus-4-5-20251101",
    // "model": "anthropic/claude-opus-4-6",
    // "model": "anthropic/claude-opus-4-7",
    // "model": "anthropic/claude-sonnet-4-20250514",
    // "model": "anthropic/claude-sonnet-4-5-20250929",
    // "model": "anthropic/claude-sonnet-4-6",
    // "model": "bedrock/us.anthropic.claude-3-haiku-20240307-v1:0",
    // "model": "bedrock/us.anthropic.claude-haiku-4-5-20251001-v1:0",
    // "model": "bedrock/us.anthropic.claude-opus-4-1-20250805-v1:0",
    // "model": "bedrock/us.anthropic.claude-opus-4-5-20251101-v1:0",
    // "model": "bedrock/us.anthropic.claude-opus-4-6-v1",
    // "model": "bedrock/us.anthropic.claude-opus-4-7",
    // "model": "bedrock/us.anthropic.claude-sonnet-4-20250514-v1:0",
    // "model": "bedrock/us.anthropic.claude-sonnet-4-5-20250929-v1:0",
    "model": "bedrock/us.anthropic.claude-sonnet-4-6",
    "messages": [
        {
            "role": "user",
            "content": "Hello"
        },
        {
            "role": "assistant",
            "content": "Hello " // trailing whitespace
        }
    ]
}'
```

### anthropic integration (v1/messages)

```
curl --location 'http://localhost:8080/anthropic/v1/messages' \
--header 'Content-Type: application/json' \
--data '{
    // "model": "anthropic/claude-haiku-4-5-20251001",
    // "model": "anthropic/claude-opus-4-1-20250805",
    // "model": "anthropic/claude-opus-4-20250514",
    // "model": "anthropic/claude-opus-4-5-20251101",
    // "model": "anthropic/claude-opus-4-6",
    // "model": "anthropic/claude-opus-4-7",
    // "model": "anthropic/claude-sonnet-4-20250514",
    // "model": "anthropic/claude-sonnet-4-5-20250929",
    // "model": "anthropic/claude-sonnet-4-6",
    // "model": "bedrock/us.anthropic.claude-3-haiku-20240307-v1:0",
    // "model": "bedrock/us.anthropic.claude-haiku-4-5-20251001-v1:0",
    // "model": "bedrock/us.anthropic.claude-opus-4-1-20250805-v1:0",
    // "model": "bedrock/us.anthropic.claude-opus-4-5-20251101-v1:0",
    // "model": "bedrock/us.anthropic.claude-opus-4-6-v1",
    // "model": "bedrock/us.anthropic.claude-opus-4-7",
    // "model": "bedrock/us.anthropic.claude-sonnet-4-20250514-v1:0",
    // "model": "bedrock/us.anthropic.claude-sonnet-4-5-20250929-v1:0",
    "model": "bedrock/us.anthropic.claude-sonnet-4-6",
    "messages": [
        {
            "role": "user",
            "content": "Hello"
        },
        {
            "role": "assistant",
            "content": "Hey "
    ]
}'
```

```
"messages": [
        {
            "role": "user",
            "content": "Hello"
        },
        {
            "role": "assistant",
            "content": [
                {
                    "type": "text",
                    "text": "Hey "
                }
            ]
        }
    ]
```

## Breaking changes

- [ ] Yes
- [x] No

## Related issues

## Security considerations

No security implications. This change only modifies outbound message content formatting before it reaches the provider API.

## Checklist

- [x] I read `docs/contributing/README.md` and followed the guidelines
- [x] I added/updated tests where appropriate
- [x] I updated documentation where needed
- [x] I verified builds succeed (Go and UI)
- [x] I verified the CI pipeline passes locally if applicable
akshaydeo pushed a commit that referenced this pull request May 20, 2026
…ovider (#3496)

## Summary

Trailing whitespace (spaces, newlines, carriage returns, tabs) in the last assistant message is stripped before sending requests to Anthropic and Bedrock (Anthropic models). This prevents API errors that can occur when assistant prefill messages end with whitespace, which Anthropic's API rejects.

## Changes

- For the Anthropic provider, all text content blocks in the final assistant message are right-trimmed of whitespace before the request is sent, applied in both `chat.go` and `responses.go`.
- For the Bedrock provider, the same trimming is applied to text blocks in the final assistant message, but only when the target model is an Anthropic model (since prefill is an Anthropic-specific concept), applied in both `chat.go` and `responses.go`.

## Type of change

- [x] Bug fix
- [ ] Feature
- [ ] Refactor
- [ ] Documentation
- [ ] Chore/CI

## Affected areas

- [x] Core (Go)
- [ ] Transports (HTTP)
- [x] Providers/Integrations
- [ ] Plugins
- [ ] UI (React)
- [ ] Docs

## How to test

Send a chat completion request where the last message has `role: assistant` and its content ends with trailing whitespace or newlines.

### chat completions

```
curl --location 'http://localhost:8080/v1/chat/completions' \
--header 'Content-Type: application/json' \
--data '{
    // "model": "anthropic/claude-haiku-4-5-20251001",
    // "model": "anthropic/claude-opus-4-1-20250805",
    // "model": "anthropic/claude-opus-4-20250514",
    // "model": "anthropic/claude-opus-4-5-20251101",
    // "model": "anthropic/claude-opus-4-6",
    // "model": "anthropic/claude-opus-4-7",
    // "model": "anthropic/claude-sonnet-4-20250514",
    // "model": "anthropic/claude-sonnet-4-5-20250929",
    // "model": "anthropic/claude-sonnet-4-6",
    // "model": "bedrock/us.anthropic.claude-3-haiku-20240307-v1:0",
    // "model": "bedrock/us.anthropic.claude-haiku-4-5-20251001-v1:0",
    // "model": "bedrock/us.anthropic.claude-opus-4-1-20250805-v1:0",
    // "model": "bedrock/us.anthropic.claude-opus-4-5-20251101-v1:0",
    // "model": "bedrock/us.anthropic.claude-opus-4-6-v1",
    // "model": "bedrock/us.anthropic.claude-opus-4-7",
    // "model": "bedrock/us.anthropic.claude-sonnet-4-20250514-v1:0",
    // "model": "bedrock/us.anthropic.claude-sonnet-4-5-20250929-v1:0",
    "model": "bedrock/us.anthropic.claude-sonnet-4-6",
    "messages": [
        {
            "role": "user",
            "content": "Hello"
        },
        {
            "role": "assistant",
            "content": "Hello " // trailing whitespace
        }
    ]
}'
```

### anthropic integration (v1/messages)

```
curl --location 'http://localhost:8080/anthropic/v1/messages' \
--header 'Content-Type: application/json' \
--data '{
    // "model": "anthropic/claude-haiku-4-5-20251001",
    // "model": "anthropic/claude-opus-4-1-20250805",
    // "model": "anthropic/claude-opus-4-20250514",
    // "model": "anthropic/claude-opus-4-5-20251101",
    // "model": "anthropic/claude-opus-4-6",
    // "model": "anthropic/claude-opus-4-7",
    // "model": "anthropic/claude-sonnet-4-20250514",
    // "model": "anthropic/claude-sonnet-4-5-20250929",
    // "model": "anthropic/claude-sonnet-4-6",
    // "model": "bedrock/us.anthropic.claude-3-haiku-20240307-v1:0",
    // "model": "bedrock/us.anthropic.claude-haiku-4-5-20251001-v1:0",
    // "model": "bedrock/us.anthropic.claude-opus-4-1-20250805-v1:0",
    // "model": "bedrock/us.anthropic.claude-opus-4-5-20251101-v1:0",
    // "model": "bedrock/us.anthropic.claude-opus-4-6-v1",
    // "model": "bedrock/us.anthropic.claude-opus-4-7",
    // "model": "bedrock/us.anthropic.claude-sonnet-4-20250514-v1:0",
    // "model": "bedrock/us.anthropic.claude-sonnet-4-5-20250929-v1:0",
    "model": "bedrock/us.anthropic.claude-sonnet-4-6",
    "messages": [
        {
            "role": "user",
            "content": "Hello"
        },
        {
            "role": "assistant",
            "content": "Hey "
    ]
}'
```

```
"messages": [
        {
            "role": "user",
            "content": "Hello"
        },
        {
            "role": "assistant",
            "content": [
                {
                    "type": "text",
                    "text": "Hey "
                }
            ]
        }
    ]
```

## Breaking changes

- [ ] Yes
- [x] No

## Related issues

## Security considerations

No security implications. This change only modifies outbound message content formatting before it reaches the provider API.

## Checklist

- [x] I read `docs/contributing/README.md` and followed the guidelines
- [x] I added/updated tests where appropriate
- [x] I updated documentation where needed
- [x] I verified builds succeed (Go and UI)
- [x] I verified the CI pipeline passes locally if applicable
@akshaydeo akshaydeo mentioned this pull request May 20, 2026
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