Skip to content

fix(github_copilot): preserve system prompts and auto-add headers - #20113

Merged
1 commit merged into
BerriAI:litellm_oss_staging_02_03_2026from
Chesars:fix/github-copilot-system-prompts
Feb 3, 2026
Merged

fix(github_copilot): preserve system prompts and auto-add headers #20113
1 commit merged into
BerriAI:litellm_oss_staging_02_03_2026from
Chesars:fix/github-copilot-system-prompts

Conversation

@Chesars

@Chesars Chesars commented Jan 31, 2026

Copy link
Copy Markdown
Contributor

Relevant issues

Fixes #19873

Pre-Submission checklist

  • I have added testing in the tests/litellm/ directory
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem

Type

🐛 Bug Fix

Changes

GitHub Copilot system prompts are not passed when routing requests because LiteLLM was converting role: system to role: assistant by default.

Why? This was a legacy workaround when the GitHub Copilot API didn't support system prompts.

Solution

  1. Remove system→assistant conversion - The API now supports system prompts natively for all models (Claude, GPT, etc.)

  2. Auto-add Copilot headers - Required headers (editor-version, user-agent, etc.) are now automatically injected for /chat/completions, same as /responses endpoint.

  3. Deprecate flag - disable_copilot_system_to_assistant is now deprecated

Before

# Required extra_headers, system prompt ignored for Claude
response = completion(
    model="github_copilot/claude-haiku-4.5",
    messages=[
        {"role": "system", "content": "You are a coding assistant"},  # ❌ Converted to assistant
        {"role": "user", "content": "Hello"}
    ],
    extra_headers={  # ❌ Required manually
        "editor-version": "vscode/1.85.1",
        "Copilot-Integration-Id": "vscode-chat"
    }
)

After

# No extra_headers needed, system prompt works
response = completion(
    model="github_copilot/claude-haiku-4.5",
    messages=[
        {"role": "system", "content": "You are a coding assistant"},  # ✅ Works
        {"role": "user", "content": "Hello"}
    ]
)

Backwards Compatibility

  • Manual extra_headers still work (user headers override defaults)
  • disable_copilot_system_to_assistant flag exists but is ignored (deprecated)

Docs

- Remove system-to-assistant message conversion (API now supports system prompts)
- Auto-inject required Copilot headers in chat completions (same as /responses)
- Deprecate disable_copilot_system_to_assistant flag
- Update docs to remove manual extra_headers requirement

Fixes BerriAI#19873
@vercel

vercel Bot commented Jan 31, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
litellm Ready Ready Preview, Comment Jan 31, 2026 5:26am

Request Review

@ghost
ghost changed the base branch from main to litellm_oss_staging_01_31_2026 January 31, 2026 18:52
@ghost
ghost changed the base branch from litellm_oss_staging_01_31_2026 to litellm_oss_staging_02_03_2026 February 3, 2026 06:05
@ghost
ghost merged commit a904c3f into BerriAI:litellm_oss_staging_02_03_2026 Feb 3, 2026
5 of 8 checks passed
@Chesars
Chesars deleted the fix/github-copilot-system-prompts branch February 3, 2026 10:44
@nadavsinai-philips

Copy link
Copy Markdown

thanks for the quick iteration! i didn't even have time to validate first...
I now got our devops to merge the addition of disable_copilot_system_to_assistant: True to the config and I find that now Both Claude and GPT models seem to work fine, I guess that Github resolved the issue with the need for "assistant" label, so the whole option can be removed IMHO.

@Chesars

Chesars commented Feb 8, 2026

Copy link
Copy Markdown
Contributor Author

You're welcome!. That's exactly what this PR does — it removes the system-to-assistant conversion by default, so you don't need to set disable_copilot_system_to_assistant: True. The flag is kept but marked as deprecated so users configs and code ( litellm.disable_copilot_system_to_assistant = True) don't break. Thanks!

KylinMountain added a commit to VectifyAI/OpenKB that referenced this pull request Jun 14, 2026
…87.2

litellm 1.87.2 fixes the chatgpt/* (ChatGPT subscription) provider
returning empty Responses output (BerriAI/litellm#25429) and auto-injects
GitHub Copilot IDE-auth headers in the chat path (BerriAI/litellm#20113).

All direct dependencies are now pinned exactly as a supply-chain
precaution (cf. the litellm package-poisoning incident) — the README
already claimed litellm was pinned to a safe version, but pyproject
carried no constraint at all. Versions match what uv.lock already
resolved, so installed behavior is unchanged apart from litellm
1.85.0 -> 1.87.2.

Refs #94
KylinMountain added a commit to VectifyAI/OpenKB that referenced this pull request Jun 14, 2026
… 1.87.2 + extra_headers) (#98)

* fix(deps): pin all dependencies to exact versions; bump litellm to 1.87.2

litellm 1.87.2 fixes the chatgpt/* (ChatGPT subscription) provider
returning empty Responses output (BerriAI/litellm#25429) and auto-injects
GitHub Copilot IDE-auth headers in the chat path (BerriAI/litellm#20113).

All direct dependencies are now pinned exactly as a supply-chain
precaution (cf. the litellm package-poisoning incident) — the README
already claimed litellm was pinned to a safe version, but pyproject
carried no constraint at all. Versions match what uv.lock already
resolved, so installed behavior is unchanged apart from litellm
1.85.0 -> 1.87.2.

Refs #94

* feat(llm): forward config extra_headers to all LLM calls; no key warning for OAuth providers

Issue #93: users on GitHub Copilot (and similar providers) need custom
HTTP headers (Editor-Version etc.) on every LLM request, and adding
extra_headers to config.yaml silently did nothing — the key was loaded
into the config dict but never forwarded.

config.resolve_extra_headers() validates/stringifies the mapping, and
cli._setup_llm_key (called by every LLM-using command) stashes it via
config.set_extra_headers(). The two call funnels read the stash:

- compiler._llm_call/_llm_call_async pass it as litellm extra_headers
  (explicit per-call kwargs still win),
- every agents-SDK Agent gets ModelSettings(extra_headers=...), which
  LitellmModel forwards to litellm.acompletion; build_chat_agent and
  skill_runner inherit it via base.clone().

Issue #94: OAuth/subscription providers (chatgpt/*, github_copilot/*)
authenticate via device flow and need no API key, so the
'No LLM API key found' warning is skipped for them.

Closes #93
Refs #94
fzowl pushed a commit to fzowl/litellm that referenced this pull request Jun 24, 2026
…erriAI#20113)

- Remove system-to-assistant message conversion (API now supports system prompts)
- Auto-inject required Copilot headers in chat completions (same as /responses)
- Deprecate disable_copilot_system_to_assistant flag
- Update docs to remove manual extra_headers requirement

Fixes BerriAI#19873
This pull request was closed.
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.

Copilot system prompts not delivered to Anthropic models due to message role transformation

2 participants