Skip to content

[openai-responses] Fold role:"system" in input to top-level instructions and strip truncation parameter #2668

Description

@Liang-Psych

Client or integration

VS Code / GitHub Copilot (via /v1/responses BYOK endpoint)

Provider or upstream service

ChatGPT Codex forward / openai-responses

OpenCodex version

2.33.0

Endpoint or capability

/v1/responses, OpenAI Responses adapter

Current behaviour

When VS Code / Copilot sends a standard prompt to gpt-5.6-luna (or other native OpenAI passthrough models), the client formats system prompts as { type: "message", role: "system", content: [...] } within input, and includes "truncation": "disabled".

OpenCodex forwards this payload directly to the ChatGPT Codex backend, which returns HTTP 502 with:

upstreamError: System messages are not allowed

or

Unsupported parameter: truncation

As a result, VS Code Copilot fails on turn start with generic code: 0 / "Sorry, your request failed".

Expected behaviour

The openai-responses forward adapter should automatically sanitize the incoming Responses payload before dispatching:

  1. Extract any role: "system" items from input, join their text content, and fold them into the top-level instructions field (string or text block).
  2. Strip the unsupported truncation parameter from the forward body.

Minimal redacted request or reproduction

  1. Send a request to POST http://127.0.0.1:7861/v1/responses:
{
  "model": "gpt-5.6-luna",
  "store": false,
  "stream": true,
  "truncation": "disabled",
  "input": [
    {
      "type": "message",
      "role": "system",
      "content": [{ "type": "input_text", "text": "You are a helpful assistant." }]
    },
    {
      "type": "message",
      "role": "user",
      "content": [{ "type": "input_text", "text": "hi" }]
    }
  ]
}
  1. Request fails with HTTP 502 (System messages are not allowed).

Actual response or error

{
  "status": 502,
  "errorCode": "upstream_server_error",
  "upstreamError": "System messages are not allowed"
}

Upstream documentation

https://platform.openai.com/docs/api-reference/responses

Suggested mapping or implementation notes

In src/adapters/openai-responses.ts:

  • Add a helper foldSystemMessagesIntoInstructions(body) that scans body.input, moves role === "system" contents to body.instructions, and keeps only non-system items in input.
  • Add stripUnsupportedTruncation(body) to drop body.truncation.
  • Insert them into the sanitizedBody processing pipeline in createResponsesPassthroughAdapter.

Checks

  • I searched existing provider and compatibility issues.
  • The request and response were redacted.
  • The expected behaviour is based on an upstream specification or a concrete client requirement.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    landed-via-maintainerOriginal PR closed after landing via a maintainer merge trainproviderProvider adapters, OpenAI-compat presets, upstream API quirksprovider-compatibilityProvider compatibility reports

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions