fix: remove Anthropic Files API usage#3466
Conversation
Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
docker-agent
left a comment
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
[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: | |||
There was a problem hiding this comment.
[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
Summary
Tests
go test ./pkg/model/provider/anthropic ./pkg/chatMOONSHOT_API_KEY= task testtask linttask build