Repository navigation
Conversation
Map inline WAV and MP3 audio parts to Chat Completions input_audio and report Audio: true, leaving per-model gating to composition and the server. Refuse URL-sourced and other audio types with a clear error. Co-Authored-By: Claude Opus 5.5 <[email protected]>
rdimitrov
left a comment
There was a problem hiding this comment.
The mapping itself is correct and matches the design in #2949: the format table, case and parameter handling, and the "adapter reports what the wire can carry" rule are consistent with the Responses adapter. The OpenCode note also holds, since openCodeLister declares ["text","image"].
I'm requesting changes for one reason: an audio part that the adapter or the server refuses now permanently breaks the session, and mecatui and ACP can reach that state for the first time.
How I tested
I built this branch and ran mecated serve against a local fake Chat Completions server over HTTPS, then drove it through the HTTP API.
- Normal use works.
audio/wave,AUDIO/X-WAV; rate=16000,audio/mpegandaudio/mp3all reached the server asinput_audiowith the right format. A 960 KB, 30-second WAV went through, and earlier clips were replayed correctly on later turns. - Tests pass:
provider/openaichatwith-race, theinternal/appcapability tests,internal/adapter/acpandcmd/mecatui/client. - Compaction strips media before summarizing, and tool results still drop audio through the fixed text-only caps, so neither path regresses.
1. A refused audio part permanently breaks the session (blocking)
recordPrompt saves the user message to history before the adapter builds the request, and every request replays the full history. A part that fails is therefore resent on every later turn:
| Case | First prompt | Plain-text follow-up | /retry |
|---|---|---|---|
audio/aiff (mecatui's http.DetectContentType sniff produces this, and audio/midi) |
openaichat: unsupported audio MIME type |
same error | – |
HTTPS URL audio (the TS SDK audioPart({ url }) allows it) |
openaichat: audio part must be inline data, not a URL |
same error | – |
| WAV sent to a model that can't hear (server returns 400) | provider request failed (400 Bad Request) |
same 400 | failed-step retry is not eligible |
The only way out is to clear the session or start a new one. The server's 400 reason never reaches the user or the server log either.
HTTP API callers could already hit this on main, but mecatui and ACP couldn't, because they gate on audio: false. With this PR they pass the gate. The codebase already guards against this kind of replay breakage for empty text blocks (the empty-render rule in engine/port/toolresult_route.go).
Suggested fix in this PR: refuse URL audio and anything other than WAV or MP3 before the prompt is saved. That could be a check in the server's prompt path, or mecatui staging only wav/mp3 types. That covers the two deterministic cases.
The server-rejection case also applies to images on non-vision models, so I think it's better as a follow-up issue than as part of this PR.
2. Existing users can't turn audio off
Custom openai-chat-completions providers (Ollama, vLLM, LM Studio, hosted Chat Completions APIs) rarely declare input in /v1/models, and their models aren't in the catalog. So every one of their sessions now reports audio: true. I confirmed this after discovery had finished, not just before it. settings.yaml has no per-model setting to narrow it.
That also applies to ACP's initialize handshake, including with opencode as the default provider (acknowledged in the description). Combined with finding 1, a text-only model plus an audio attachment now produces a broken session where it used to produce a clear local refusal. The description says a model that can't hear "is refused by its server", which understates what happens.
3. Docs
user-docs/features/sessions/multimodal-input.md: "If Mecatl offers audio for a model that cannot hear, the model's server rejects it" should say the session can't continue afterwards and how to recover, unless finding 1 is fixed.
Summary
The Chat Completions adapter refused every audio part before sending, so a
custom provider with
api_flavor: openai-chat-completionscould not send audioeven to a model that hears it. Chat Completions defines an
input_audiousercontent part, and llama.cpp's
llama-serveraccepts it for models with anaudio projector.
input_audio, with the format taken from the MIMEtype, ignoring case and parameters. Only
audio/mpegis IANA-registered; WAVhas no registered type, so each toolchain uses its own name:
audio/wav: Go's MIME tableaudio/wave: WHATWG sniffing, sohttp.DetectContentTypeandmecatuiaudio/x-wav: Pythonmimetypes, libmagic, Linux/etc/mime.typesaudio/vnd.wave: freedesktop shared-mime-info, so GIO andxdg-mimeaudio/mpegandaudio/mp3map tomp3; Chromium and shared-mime-infoboth recognize
audio/mp3as an alias ofaudio/mpeg.cause, since
input_audiocarries only inline wav or mp3 data.Audio: truefromCapabilities(). As in the Responses adapter, thebit describes what the wire can carry; per-model gating stays with
composition's model metadata and the server hosting the model.
internal/appand the multimodal inputuser documentation.
Issue relationship
Fixes #2949
Type of change
Test plan
Baseline checks
task lint)task test)task test:race)go run ./cmd/mecademo)task docs)task site:build)task api:check)task api:update+engine/CHANGELOG.mdtask site:build(needs Node 24 and pnpm) and thedocs:grpc-refstep oftask docs(needsbuf; no protobuf changes) were not run locally; left to CI.No engine API change, so
task api:checkandtask api:updatedo not apply.Manual verification
Against llama.cpp
llama-server(build b12633) servingunsloth/gemma-4-E4B-it-GGUF:Q4_K_M, using the steps in #2949: before,mecatuirefuses the attachment; after, WAV and MP3 reach the model and itanswers questions about the clip. An
audio/oggpart is refused before sending.Changes
provider/openaichat/request.goinput_audio; MIME-to-format table; refusalsprovider/openaichat/openaichat.goCapabilities()reportsAudio: true; comment states the transmit-authority ruleprovider/openaichat/multimodal_test.goopenaiandanthropicadapters' files: the image test (moved fromrequest_test.go, renamedTestBuildParamsImagePart), tests for each MIME alias, the refusals, the request body on the wire, and the capabilityprovider/openaichat/request_test.goTestBuildParamsToolResultDropsMediapins that tool messages stay text-only althoughCapabilities()now reports audioprovider/openaichat/session_header_test.godrainStreamso the new wire test reuses the stream-draining helperinternal/app/capability.go,capability_test.go,registry.gouser-docs/features/sessions/multimodal-input.mdUser-facing change
Sessions on a custom provider with
api_flavor: openai-chat-completionsadvertise audio input, and
mecatuilets users attach WAV and MP3 files. Amodel that cannot hear is refused by its server. Responses and Messages
sessions are unchanged.
Special notes for reviewers
API compatibility: no break. No contract fields change. The existing
session_capabilities.audioflag reportstruefor sessions on ChatCompletions providers (see the
opencodenote below);mecatuiand ACP alreadyhandle that value. A newly enabled capability is a discoverable addition under
the wire API policy, so no major or feature-identifier change is needed. No
stored-data or Go API change.
opencode: the built-in provider uses the same adapter, so its sessionscan advertise audio until its model listing loads; the listing declares text
and image input, which then removes audio. Default and ACP sessions compute
capabilities before discovery runs, so with
opencodeas the default providerthey advertise audio. Its server refuses audio a model cannot take. This is the
same rule the fix applies everywhere: the adapter reports what the wire can
carry, and the model's server decides.
provider/openaichatis published independently; this changes its behavior,not its exported API.