Skip to content

Consider aligning FilePart and how files are handled in ToolResultOutput #14010

@felixarntz

Description

@felixarntz

FilePart (as part of ContentPart) uses a single type: "file" with an overloaded data field (DataContent | URL, further expanded in #13816). In contrast, file content within ToolResultOutput already uses distinguishable types: file-data, file-url, file-id, etc.

This inconsistency causes practical problems:

Proposal

  • Split FilePart into multiple discriminated types, mirroring what ToolResultOutput already does.
  • Maintain the current types (e.g. "file") as deprecated parts of the union, which can be auto-mapped to the new discriminated types.
  • In the provider spec, we can make this change potentially without maintaining that back compat layer, because it has much lower exposure on the ecosystem, and helps keep the spec simple.

Note: This affects both packages/provider-utils/src/types/content-part.ts and packages/ai/src/prompt/content-part.ts.

Aside: we should also consider getting rid of the file vs image distinction, because an image is simply a file with a specific media type. That's a separate change though, potentially to implement before this one.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ai/corecore functions like generateText, streamText, etc. Provider utils, and provider spec.ai/providerrelated to a provider package. Must be assigned together with at least one `provider/*` labeldeprecationpull requests that introduced a deprecationfeatureNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions