Skip to content

feat(#3996): strip unsupported audio/video media parts - #4016

Draft
aheritier wants to merge 3 commits into
mainfrom
media-input-modalities
Draft

feat(#3996): strip unsupported audio/video media parts#4016
aheritier wants to merge 3 commits into
mainfrom
media-input-modalities

Conversation

@aheritier

@aheritier aheritier commented Aug 22, 2026

Copy link
Copy Markdown
Collaborator

What

Adds capability-aware filtering that strips unsupported audio/video media parts before provider requests, with schema, model metadata, runtime transforms, provider coverage, examples, and tests.

Why

Prevents incompatible media from reaching gateways while preserving supported modalities and making capability overrides explicit.

Validation

task test; targeted attachment, capability, modelinfo, runtime, and provider tests.

Test instructions

Run:

task test

Then run an agent with a mixed text/image/audio/video prompt against a model that does not support every modality. Expected: unsupported audio/video parts are omitted before the provider request, while text and supported image content remain.

Extend ModelCapabilities with SupportsAudio/SupportsVideo, parse the
models.dev "audio"/"video" input modalities in LoadCaps, and thread
the new fields through CapsWith, CapsOverride and ResolveCaps so every
call site keeps compiling. Unknown/uncatalogued models stay
conservative (no audio/video inferred), matching the existing
image/pdf posture.

This is foundation-only: no config schema, override wiring, or
provider behavior changes — config-level capability overrides and
provider gating build on it in later commits.
Extend CapabilitiesConfig with Audio/Video, completing the override
introduced by the previous commit for models the models.dev catalogue
does not describe correctly (custom OpenAI-compatible providers, local
models, dropped catalogue entries) — without it such models silently
lose audio/video attachments the same way image/PDF did before
capabilities existed (issue #2741). Update schema, docs, and example;
CapsOverride now threads all four flags through to modelinfo.
Generalize the strip_unsupported_modalities transform from image-only to
all three media families (image/audio/video), classified by MIME family
from Document/File parts (legacy ImageURL parts stay image).

The transform now consumes the already-resolved capability set instead
of querying models.dev itself: the loop resolves capabilities for the
model it actually chose (per-tool override + alloy pick) via the new
modelinfo.ResolveCapsFromModel — explicit capabilities: config
overrides win, unknown models resolve to the conservative text-only
default — and threads the result through hooks.Input.ModelCapabilities
(json:"-", in-process only). This fixes the override bug where a model
declared capabilities.audio/image: true still had its media stripped
based on the catalogue, and aligns unknown-model behavior with the
attachment pipeline's conservative posture. Each stripped part emits a
debug log naming its media kind and reason.

Harness labels carry no resolvable capabilities, so that path passes
nil and capability-gated transforms skip, preserving harness behavior.
@aheritier aheritier added area/config For configuration parsing, YAML, environment variables area/docs Documentation changes area/providers For features/issues/fixes related to LLM providers (Bedrock, LiteLLM, Qwen, custom, etc.) area/providers/openai For features/issues/fixes related to the usage of OpenAI models area/providers/anthropic For features/issues/fixes related to the usage of Anthropic models area/providers/bedrock AWS Bedrock provider support area/providers/gemini Google Gemini provider support area/runtime Runtime engine, agent loop execution, tool dispatch, loop detection area/testing Test infrastructure, CI/CD, test runners, evaluation kind/feat PR adds a new feature (maps to feat:). Use on PRs only. labels Aug 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/config For configuration parsing, YAML, environment variables area/docs Documentation changes area/providers/anthropic For features/issues/fixes related to the usage of Anthropic models area/providers/bedrock AWS Bedrock provider support area/providers/gemini Google Gemini provider support area/providers/openai For features/issues/fixes related to the usage of OpenAI models area/providers For features/issues/fixes related to LLM providers (Bedrock, LiteLLM, Qwen, custom, etc.) area/runtime Runtime engine, agent loop execution, tool dispatch, loop detection area/testing Test infrastructure, CI/CD, test runners, evaluation kind/feat PR adds a new feature (maps to feat:). Use on PRs only.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant