Skip to content

fix: inject placeholder message when Responses API input[] is empty - #419

Merged
decolua merged 1 commit into
decolua:masterfrom
anuragg-saxenaa:fix/issue-389-responses-empty-input
Mar 27, 2026
Merged

decolua merged 1 commit into
decolua:masterfrom
anuragg-saxenaa:fix/issue-389-responses-empty-input

Conversation

@anuragg-saxenaa

Copy link
Copy Markdown
Contributor

Closes #389\n\n## Problem\nWhen a client (e.g. Fabric-AI) calls POST /v1/responses with an empty input:[] array, normalizeResponsesInput returned the empty array unchanged. The translator then produced messages:[] which upstream providers reject with:\n400: messages: at least one message is required\n9router surfaced this as a 406.\n\n## Fix\nIn normalizeResponsesInput, treat input:[] the same as input:"" — inject a placeholder user message so the request is always valid.\n\n## Files changed\n- open-sse/translator/helpers/responsesApiHelper.js — 1 guard added

@decolua
decolua merged commit 5abf710 into decolua:master Mar 27, 2026
idbara pushed a commit to idbara/9router that referenced this pull request Apr 23, 2026
luckystart79-lang pushed a commit to luckystart79-lang/minirouter that referenced this pull request May 2, 2026
caothu159 pushed a commit to diepxuan/9router that referenced this pull request May 14, 2026
diegosouzapw added a commit to diegosouzapw/OmniRoute that referenced this pull request Jun 20, 2026
…] is empty

A client (e.g. Fabric-AI) calling POST /v1/responses with `input: []`
used to be translated into `messages: []`, which every upstream Chat-
Completions provider rejects with `400: at least one message is required`
(surfaced to the client as a confusing 406).

Mirror the existing empty-string handling: when input[] is empty, inject
a single placeholder user message so the request is always valid. Touches
`openaiResponsesToOpenAIRequest` only (the same translator that already
covers the empty-string case at the top of the function), preserves any
caller-supplied `instructions` as a system message, and leaves every
non-empty input path byte-identical.

Adds a TDD test reproducing the empty input[] case (RED before fix, GREEN
after) and updates one pre-existing test that enshrined the broken
behavior (`assert.deepEqual(call.body.messages, [])`) to assert the new
correct shape.

Co-authored-by: anuragg-saxenaa <anuragg.saxenaa@gmail.com>
Inspired-by: decolua/9router#419
diegosouzapw added a commit to diegosouzapw/OmniRoute that referenced this pull request Jun 20, 2026
…] is empty (#4393)

A client (e.g. Fabric-AI) calling POST /v1/responses with `input: []`
used to be translated into `messages: []`, which every upstream Chat-
Completions provider rejects with `400: at least one message is required`
(surfaced to the client as a confusing 406).

Mirror the existing empty-string handling: when input[] is empty, inject
a single placeholder user message so the request is always valid. Touches
`openaiResponsesToOpenAIRequest` only (the same translator that already
covers the empty-string case at the top of the function), preserves any
caller-supplied `instructions` as a system message, and leaves every
non-empty input path byte-identical.

Adds a TDD test reproducing the empty input[] case (RED before fix, GREEN
after) and updates one pre-existing test that enshrined the broken
behavior (`assert.deepEqual(call.body.messages, [])`) to assert the new
correct shape.


Inspired-by: decolua/9router#419

Co-authored-by: anuragg-saxenaa <anuragg.saxenaa@gmail.com>
tkgo11 pushed a commit to tkgo11/OmniRoute that referenced this pull request Sep 23, 2026
…] is empty (diegosouzapw#4393)

A client (e.g. Fabric-AI) calling POST /v1/responses with `input: []`
used to be translated into `messages: []`, which every upstream Chat-
Completions provider rejects with `400: at least one message is required`
(surfaced to the client as a confusing 406).

Mirror the existing empty-string handling: when input[] is empty, inject
a single placeholder user message so the request is always valid. Touches
`openaiResponsesToOpenAIRequest` only (the same translator that already
covers the empty-string case at the top of the function), preserves any
caller-supplied `instructions` as a system message, and leaves every
non-empty input path byte-identical.

Adds a TDD test reproducing the empty input[] case (RED before fix, GREEN
after) and updates one pre-existing test that enshrined the broken
behavior (`assert.deepEqual(call.body.messages, [])`) to assert the new
correct shape.


Inspired-by: decolua/9router#419

Co-authored-by: anuragg-saxenaa <anuragg.saxenaa@gmail.com>
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.

cli fabric-ai failed with OpenAI, Anthrophic and Ollama API

2 participants