Skip to content

fix(server): reject multiple completion prompts with a client error - #2418

Open
remote-controlled-man wants to merge 2 commits into
abetlen:mainfrom
remote-controlled-man:codex/prflow-243c40fe65a1
Open

remote-controlled-man wants to merge 2 commits into
abetlen:mainfrom
remote-controlled-man:codex/prflow-243c40fe65a1

Conversation

@remote-controlled-man

Copy link
Copy Markdown
Contributor

Problem

POST /v1/completions with {"prompt": ["first", "second"]} reaches an assertion and returns HTTP 500 with an empty internal error message. With Python optimization enabled, the assertion disappears and the server silently uses only the first prompt.

The legacy /v1/engines/copilot-codex/completions route shares this behavior, for both streaming and non-streaming requests.

Change

Return HTTP 400 with Only a single prompt is supported. before acquiring the model or creating a stream. Keep the existing behavior for string prompts, single-item arrays, and empty arrays.

Add HTTP regression tests using the real application and a fake inference model. They cover both routes and streaming modes, multiple prompts (including two empty strings), and supported-input controls.

Validation

On macOS arm64, Python 3.12.14, with the native library built from the pinned llama.cpp submodule using the installed macOS 15.4 SDK:

  • The 28 HTTP regression/control cases pass normally and with python -O.
  • On the original source, 12 rejection cases fail with HTTP 500 normally and HTTP 200 under -O; the 16 supported-input controls pass.
  • Full make test: 54 passed, including the real-model fixtures and the HTTP regressions.
  • Full make lint: Ruff checks pass and all 30 Python files pass the format check.

The HTTP regressions isolate model loading; the full suite separately exercises the upstream real-model fixtures. No GPU/backend behavior is changed.

Copilot AI balanced review requested due to automatic review settings November 17, 2026 13:59

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

This branch has not been deployed

No deployments
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.

2 participants