Skip to content

Feature: Make storing file message parts in history configurable (keep URL-only attachments) #129

@DiegoJohnsonL

Description

@DiegoJohnsonL

Problem
@ai-sdk-tools/agents currently strips type: "file" parts from user messages before saving chat history. This breaks workflows where attachments are already-uploaded URLs (e.g. Vercel Blob) and need to remain available on later turns for tool calls (“use the attached image”).

Where
packages/agents/src/agent.ts filters user message parts with:

  • part.type !== "file" (file parts excluded from storage)

Why this matters
Many apps send “attachments” as { type: "file", url: "https://..." } (not raw bytes). Dropping these means the agent can’t reference the attachment in follow-up turns, so tools expecting fileUrl can’t reliably work.

Request
Add a config option to control file-part persistence in history, defaulting to current safe behavior:

  • history.fileParts: "drop" | "keep-urls" | "keep-all" (default "drop")

Suggested behavior:

  • keep-urls: store only URL-based file parts (and optionally allowlist hosts), drop binary/base64.

Example

{
  "role": "user",
  "content": [
    { "type": "file", "mediaType": "image/png", "filename": "x.png", "url": "https://public-blob-url" },
    { "type": "text", "text": "Upload this image to Strapi" }
  ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions