Skip to content

feat(core): promote managed attachment media on first turn - #46182

Draft
safzanpirani wants to merge 2 commits into
anomalyco:devfrom
safzanpirani:attachment-media
Draft

feat(core): promote managed attachment media on first turn#46182
safzanpirani wants to merge 2 commits into
anomalyco:devfrom
safzanpirani:attachment-media

Conversation

@safzanpirani

Copy link
Copy Markdown

Issue for this PR

Closes #46173 (PR 2 of the 3-PR plan there; stacked on #46175 — only the top commit f9e6c06c6 is this PR's diff, the rest is #46175's base)

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Native media delivery for managed attachments. On the first provider turn that consumes a prompt, a stored image or PDF is sent as native media (path in the media part's filename) when the model's catalog capabilities, the sniffed MIME, the protocol route, and the decoded-size limit all allow it. Anything disqualified degrades to the path-only text part from #46175 instead of aborting. Later turns replay path-only — the file is never re-read or re-encoded, and no base64 is persisted (the #42263 failure class). Delivery is at-most-once via a durable nativeMediaDeliveredAt marker written before provider I/O. Media admission is owned by each protocol (Chat Completions: images only; Responses/Anthropic/Gemini: images + PDF), so core can't drift from what lowering accepts.

How did you verify your code works?

  • packages/core: focused suites 124 pass — includes a two-real-runner-turn test with a recording LLM client that kills and reopens the runtime/store between turns, then asserts the replay request is path-only and raw session_message rows contain no media base64. Typecheck clean.
  • packages/llm: 300 pass / 30 skipped, typecheck clean — per-protocol admission and PDF lowering tests for Responses, Anthropic, Gemini; Chat Completions PDF rejection.
  • packages/opencode: HTTP attachment suite 5 pass.

Screenshots / recordings

Not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Based on my search results, I found one related PR that is not a duplicate but rather a stacked dependency:

Related PR (not a duplicate):

This is intentional as per the PR description which states this is "PR 2 of the 3-PR plan" and only the top commit represents the current PR's diff, with the rest being #46175's base.

The searches also found PR #43314 about degrading undecodable image attachments, but this is addressing a different concern (error handling) rather than native media delivery.

No duplicate PRs found

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.

[FEATURE]: upload attachments to the server so agent tools can read them (managed per-session store)

1 participant