Skip to content

Reasoning types & reasoning_effort passthrough in chat-completions #7

@HXYerror

Description

@HXYerror

Part of #1.

Goal

Even on the legacy `/chat/completions` path, reasoning models (`gpt-5`, `o1`, `o3`, `o4-mini`) accept a top-level `reasoning_effort` parameter and may return a `choices[].message.reasoning_content` field. copilot-api currently drops both — the type definitions don't even mention them.

Current state

`src/services/copilot/create-chat-completions.ts:127–151` defines `ChatCompletionsPayload` with these fields and no others:

```
messages, model, temperature, top_p, max_tokens, stop, n, stream,
frequency_penalty, presence_penalty, logit_bias, logprobs,
response_format, seed, tools, tool_choice, user
```

`Delta` and `ResponseMessage` types (`create-chat-completions.ts:72–123`) have no `reasoning_content` field.

Grep for `reasoning|reasoning_effort|reasoning_content` across the entire repo → 0 hits.

Tasks

  • Add `reasoning_effort?: "minimal" | "low" | "medium" | "high"` to `ChatCompletionsPayload` so client requests pass through
  • Add `reasoning_content?: string` to `Delta` and `ResponseMessage` so streamed/non-streamed reasoning text round-trips back to the client without being silently dropped at the type boundary
  • Confirm zod schemas (if any) accept these fields without `.strict()` rejection
  • When forwarding to Copilot upstream, pass these fields through unmodified (they are valid OpenAI API fields)

Acceptance criteria

  • A client that sends `reasoning_effort: "high"` to `/v1/chat/completions` with `gpt-5` sees the parameter reach upstream (verifiable with `--verbose`)
  • A reasoning-content delta returned by upstream appears in the streamed response to the client
  • Non-reasoning models (`gpt-4o`) are unaffected

Notes

This is the degraded-mode fallback path. Multi-turn `encrypted_content` round-trip is not possible on `/chat/completions` (that's why #1 exists). But `reasoning_effort` and single-turn `reasoning_content` visibility are still worth having here as a baseline.

Metadata

Metadata

Assignees

No one assigned

    Labels

    reasoningReasoning / thinking / encrypted_contentresponses-apiOpenAI /v1/responses API support

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions