Skip to content

fix: remove Anthropic Files API usage#3466

Merged
rumpl merged 1 commit into
docker:mainfrom
rumpl:remove-anthropic-files-api
Jul 4, 2026
Merged

fix: remove Anthropic Files API usage#3466
rumpl merged 1 commit into
docker:mainfrom
rumpl:remove-anthropic-files-api

Conversation

@rumpl

@rumpl rumpl commented Jul 3, 2026

Copy link
Copy Markdown
Member

Summary

  • remove Anthropic Files API upload/delete manager and tests
  • stop adding the files-api beta header or routing legacy file parts to Anthropic file IDs
  • keep legacy message part structs for stored-session compatibility while documenting that new attachments should use documents

Tests

  • go test ./pkg/model/provider/anthropic ./pkg/chat
  • MOONSHOT_API_KEY= task test
  • task lint
  • task build

Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
@rumpl rumpl requested a review from a team as a code owner July 3, 2026 23:55
@rumpl rumpl enabled auto-merge July 3, 2026 23:56

@docker-agent docker-agent 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.

Assessment: 🟢 APPROVE

The PR cleanly removes the Anthropic Files API (FileManager, upload/delete logic, the files-api beta header, and the routing guard). Legacy MessagePartTypeFile structs are retained for stored-session deserialization compatibility — a good design choice. Two minor observability gaps were found in the new MessagePartTypeFile handling paths.

}))
}

case chat.MessagePartTypeFile:

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.

[LOW] Legacy FileID-only file parts silently dropped with no warning in non-beta path

When a stored session contains a MessagePartTypeFile part where part.File == nil (i.e., only a FileID string is present, no local file object), this case reaches the convertUserMultiContent non-beta path and silently skips the part with no log entry. The part.File != nil branch correctly logs a deprecation warning, but the FileID-only case goes unlogged.

Consider also warning when part.File == nil (e.g. checking part.FileID != ""):

case chat.MessagePartTypeFile:
    if part.File != nil {
        slog.WarnContext(ctx, "anthropic: dropping legacy file attachment; use document attachments instead", "path", part.File.Path)
    } else if part.FileID != "" {
        slog.WarnContext(ctx, "anthropic: dropping legacy Files-API file ID; use document attachments instead", "file_id", part.FileID)
    }

@@ -294,41 +288,7 @@ func (c *Client) convertBetaUserMultiContent(ctx context.Context, parts []chat.M
}

case chat.MessagePartTypeFile:

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.

[LOW] Beta path silently drops legacy file parts with no log warning (inconsistent with non-beta path)

The non-beta path (convertUserMultiContent) logs a slog.WarnContext deprecation message when it encounters a MessagePartTypeFile part, but the beta path here uses a bare continue with no log output. A session that reaches createBetaStream (e.g. because it uses structured output or extended thinking) with legacy file parts will silently lose those attachments with no operator-visible signal.

For consistency, add the same warning here:

case chat.MessagePartTypeFile:
    if part.File != nil {
        slog.WarnContext(ctx, "anthropic: dropping legacy file attachment; use document attachments instead", "path", part.File.Path)
    }
    continue

@aheritier aheritier added area/providers/anthropic For features/issues/fixes related to the usage of Anthropic models kind/fix PR fixes a bug (maps to fix:). Use on PRs only. labels Jul 4, 2026
@rumpl rumpl merged commit e17c58d into docker:main Jul 4, 2026
11 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/providers/anthropic For features/issues/fixes related to the usage of Anthropic models kind/fix PR fixes a bug (maps to fix:). Use on PRs only.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants