interactions: response.failed events are dropped by all stream translators — devin trailer errors surface only as in-band SSE under HTTP 200

Author: aPipixia123456Created Sep 29, 2026Updated Sep 30, 2026
LabelsFixed

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

  1. Devin upstream delivers the error inside a Connect-RPC end-stream trailer frame, after response data has already started. internal/runtime/executor/devin_executor.go parses it via helps.ParseDevinTrailerError and logs trailer error.
  2. The executor then does two things:
    • emits {"event_type":"response.failed","error":{...}} through emitInteractionsEvent, i.e. sdktranslator.TranslateStream(FormatInteractions -> responseFormat)
    • pushes StreamChunk{Err: statusErr{403,...}} into the output channel
  3. Step 2a produces zero bytes: in internal/translator/openai/interactions/chat-completions/openai_interactions_response.go (convertInteractionsEventToOpenAIChat), the event_type switch only covers interaction.created, step.start, step.delta, interaction.completed/finish, done. response.failed falls through to return 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 reference response.failed anywhere in internal/translator.
  4. Step 2b does surface something: handlers_stream.go forwards chunk.Err to errChan, and ForwardStream.WriteTerminalError writes data: {"error":{...}}. But HTTP status was already committed as 200 when interaction.created produced the first chat chunk, so any downstream that keys on status code (or only understands chat.completion.chunk JSON) 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: a response.failed SSE event (the responses wire format already has one)
  • -> claude: an error SSE 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 on devin/kimi-k3
  • Downstream: OpenAI chat-completions clients via an API gateway (which logs the request as a 200 success)

Source: router-for-me/CLIProxyAPI