interactions: response.failed events are dropped by all stream translators — devin trailer errors surface only as in-band SSE under HTTP 200
Summary
When a Devin upstream request fails with a Connect-RPC trailer error (e.g. 403 permission_denied), the executor correctly detects the failure and emits a {"event_type":"response.failed","error":{...}} interaction event — but no FormatInteractions -> X stream response translator handles response.failed, so the event is silently dropped. Downstream clients receive HTTP 200 plus (at best) a generic in-band data: {"error":{...}} frame, and no format-native failure signal.
Observed behavior
Production log excerpt (CPA v7.3.4):
[warn] devin_executor.go:754 devin executor: trailer error (403): devin upstream error (permission_denied): Unable to process request due to an MCP configuration issue.
[warn] conductor_execution.go 403 | upstream execution failed: provider=devin model=devin/kimi-k3
[info] gin_logger.go 200 | POST "/v1/chat/completions"The same request is recorded as 403 upstream execution failed internally, yet 200 at the HTTP layer. In our deployment ~46% of requests to this provider failed upstream while every downstream status was 200.
Root cause chain
- Devin upstream delivers the error inside a Connect-RPC end-stream trailer frame, after response data has already started.
internal/runtime/executor/devin_executor.goparses it viahelps.ParseDevinTrailerErrorand logstrailer error. - The executor then does two things:
- emits
{"event_type":"response.failed","error":{...}}throughemitInteractionsEvent, i.e.sdktranslator.TranslateStream(FormatInteractions -> responseFormat) - pushes
StreamChunk{Err: statusErr{403,...}}into the output channel
- emits
- Step 2a produces zero bytes: in
internal/translator/openai/interactions/chat-completions/openai_interactions_response.go(convertInteractionsEventToOpenAIChat), theevent_typeswitch only coversinteraction.created,step.start,step.delta,interaction.completed/finish,done.response.failedfalls through toreturn nil. The same is true for the other interactions response translators (openai/interactions/responses,interactions/claude,antigravity/interactions,gemini/interactions,codex/interactions) — none of them referenceresponse.failedanywhere ininternal/translator. - Step 2b does surface something:
handlers_stream.goforwardschunk.ErrtoerrChan, andForwardStream.WriteTerminalErrorwritesdata: {"error":{...}}. But HTTP status was already committed as200wheninteraction.createdproduced the first chat chunk, so any downstream that keys on status code (or only understandschat.completion.chunkJSON) treats this as a truncated-but-successful response.
Suggestion
Handle response.failed (and possibly interaction.failed) in every FormatInteractions -> X stream response translator, emitting the format-native failure signal, e.g.:
-> openai chat: an error chunk or a final chunk carrying the error before the terminal SSE error frame-> openai-response: aresponse.failedSSE event (the responses wire format already has one)-> claude: anerrorSSE event-> gemini/interactions: whatever the corresponding format uses
Even where the generic WriteTerminalError frame already fires, a format-native failure event gives clients a documented, parseable signal instead of an out-of-schema {"error":...} data frame.
Optionally: for non-streaming requests the trailer error path already returns a proper status — the gap is stream-only.
Environment
- CLIProxyAPI v7.3.4
- Provider:
devin(devin_executor.go), observed ondevin/kimi-k3 - Downstream: OpenAI chat-completions clients via an API gateway (which logs the request as a 200 success)
Source: router-for-me/CLIProxyAPI