Skip to content

Support media inputs in stdlib LLM clients - #4369

Closed
aaronvg wants to merge 2 commits into
canaryfrom
codex/stdlib-media-inputs
Closed

aaronvg wants to merge 2 commits into
canaryfrom
codex/stdlib-media-inputs

Conversation

@aaronvg

@aaronvg aaronvg commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

What changed

  • Preserve structured prompt parts through ai.Prompt.messages() instead of flattening media into readable placeholders.
  • Resolve local files, base64/data URLs, HTTP URLs, MIME types, and Google Cloud URLs before provider lowering.
  • Lower image, audio, PDF, and video inputs into the native OpenAI Responses, Anthropic Messages, and Gemini request shapes.
  • Match sys_llm provider capabilities: Gemini supports all four media kinds; OpenAI and Anthropic support image/audio/PDF and return an explicit error for video.
  • Add structural prompt and provider request-body regression coverage, including Gemini video.

Why

The new stdlib clients consumed the readable PromptMessage.content projection. That converted BAML media values into placeholder text before provider request construction, so LLM functions with image, audio, video, or pdf inputs could not send the media to the model. The clients now consume ordered structural prompt parts and lower each media value at the provider boundary.

Impact

BAML LLM functions using media input types now work through the new stdlib provider clients. Existing readable prompt inspection remains unchanged through PromptMessage.content and Prompt.text().

Validation

  • cargo fmt --all -- --check
  • cargo nextest run -p baml_tests -E 'test(~__ai_std__)'
  • cargo nextest run -p baml_tests --test promptast_accessors --test structured_prompt_requests
  • cargo nextest run -p baml_builtins2 -p bex_vm
  • Live local-image test with Infisical through OpenAI, then Gemini

Note

Medium Risk
Changes provider request construction and media resolution (file I/O and HTTP fetches) across OpenAI, Anthropic, and Gemini clients. Readable prompt inspection is unchanged, but incorrect lowering could send malformed multimodal payloads.

Overview
Media inputs now reach the model through stdlib LLM clients instead of being flattened into readable placeholders before request construction.

PromptMessage gains a structural parts field (string | MediaPart). Rust PromptAst exposes to_structured_messages() so media survives messages(), while content / text() stay as the readable projection.

Adds shared ai.wire.resolve_media to resolve local files, base64/data URLs, HTTP(S) fetches, MIME types, and gs:// URLs before provider lowering.

OpenAI Responses, Anthropic Messages, and Gemini now lower those parts into native request shapes. Gemini accepts all four media kinds; OpenAI and Anthropic accept image/audio/PDF and reject video.

Reviewed by Cursor Bugbot for commit bf12bcd. Bugbot is set up for automated code reviews on this repo. Configure here.

@vercel

vercel Bot commented Aug 12, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
beps Ready Ready Preview Aug 12, 2026 5:13am
promptfiddle2 Ready Ready Preview Aug 12, 2026 5:13am

Request Review

@coderabbitai

coderabbitai Bot commented Aug 12, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 9362a440-a96d-497a-83c5-3281964dae3a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

⏭️ Performance benchmarks were skipped

Perf benchmarks (CodSpeed) are opt-in on pull requests — they no longer run on every push. They always run automatically after merge to canary/main.

To run them on this PR, do any of the following, then push a commit (or re-run CI):

  • Add RUN_CODSPEED=1 to the PR description, or
  • Include run-perf or /perf in the PR title or any commit message.

@vercel
vercel Bot temporarily deployed to Preview – beps August 12, 2026 04:56 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 August 12, 2026 05:03 Inactive
@vercel
vercel Bot temporarily deployed to Preview – beps August 12, 2026 05:05 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 August 12, 2026 05:13 Inactive
@github-actions

Copy link
Copy Markdown

Binary size checks passed

✅ 7 passed

Artifact Platform File Gzip Gated on Baseline Delta Status
✅ baml-cli Linux 🔒 26.2 MB 11.1 MB file 27.4 MB -1.2 MB (-4.4%) OK
✅ packed-program Linux 🔒 16.9 MB 6.9 MB file 18.6 MB -1.6 MB (-8.7%) OK
✅ baml-cli macOS 🔒 20.4 MB 9.7 MB file 21.3 MB -897.4 KB (-4.2%) OK
✅ packed-program macOS 🔒 13.4 MB 6.0 MB file 14.5 MB -1.1 MB (-7.6%) OK
✅ baml-cli Windows 🔒 21.9 MB 9.9 MB file 23.0 MB -1.1 MB (-4.6%) OK
✅ packed-program Windows 🔒 14.1 MB 6.1 MB file 15.5 MB -1.4 MB (-8.8%) OK
✅ bridge_wasm WASM 15.5 MB 🔒 4.2 MB gzip 4.6 MB -434.4 KB (-9.4%) OK

🔒 = the size this artifact is GATED on (ceiling + delta). Binaries gate on file size (installed binary); WASM gates on gzip (download size). The other size is shown for information only.


Generated by cargo size-gate · workflow run

@aaronvg

aaronvg commented Aug 26, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #4430 (native provider clients, which deleted sys_llm and landed structural prompt parts + resolve_media + provider media lowering natively) and #4459. Remaining host-boundary media gaps (HS-1/HS-2) are fixed in #4604.

@aaronvg aaronvg closed this Aug 26, 2026

This branch was previously deployed

2 inactive deployments
Preview – promptfiddle2 — bf12bcd4 Deployed Aug 12, 2026 by vercel[bot]
Preview – beps — bf12bcd4 Deployed Aug 12, 2026 by vercel[bot]
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.

1 participant