Skip to content

fix(copilot): VS Code Copilot always reports the account default model instead of the user-selected mode#1560

Open
jorgegarciarey wants to merge 3 commits into
git-ai-project:mainfrom
jorgegarciarey:fix/copilot-vscode-model-from-otel
Open

fix(copilot): VS Code Copilot always reports the account default model instead of the user-selected mode#1560
jorgegarciarey wants to merge 3 commits into
git-ai-project:mainfrom
jorgegarciarey:fix/copilot-vscode-model-from-otel

Conversation

@jorgegarciarey

@jorgegarciarey jorgegarciarey commented Jun 15, 2026

Copy link
Copy Markdown

Fixes #1559

Problem

When using GitHub Copilot Chat from VS Code (agent mode), git-ai always attributes commits to the account's default model (e.g. gpt-5.3-codex) regardless of which model the user actually selected in the chat picker.

Root cause

VS Code's chat transcripts contain no model field in any entry (session.start, user.message, assistant.message, etc.). The session.model_change event that git-ai relies on is only emitted by the Copilot CLI, not by VS Code. As a result model_extraction::extract_model returns None for VS Code transcripts and the resolution chain falls through to the models.json fallback, which returns the entry with is_chat_default == true — the account default, not the user-selected model.

Fix

VS Code's Copilot extension records the real per-request model in its OTel SQLite DB agent-traces.db, located at .../User/globalStorage/github.copilot-chat/agent-traces.db. The spans table has a chat_session_id column matching the transcript file stem, plus request_model / response_model columns.

This PR:

  • Adds extract_model_from_copilot_otel_db (and helper resolve_copilot_otel_db_path) in src/streams/model_extraction.rs, which queries spans by chat_session_id, preferring request_model over response_model, ordered by most recent end_time_ms. The DB path can be overridden via GIT_AI_COPILOT_OTEL_DB_PATH for testing.
  • Wires the OTel lookup into the VS Code native hooks parser in src/commands/checkpoint_agent/presets/github_copilot/ide.rs, between transcript extraction and the models.json fallback, so the correct model is resolved before the account-default fallback kicks in.

Testing

  • 5 new unit tests covering: prefers request_model, falls back to response_model, uses most recent span, ignores other sessions, and missing DB.
  • cargo test --lib model_extraction — 24 passed, 0 failed.
  • cargo fmt and cargo clippy --all-targets -- -D warnings — clean.
  • cargo build — success.

The change is read-only against the OTel DB (opened read-only) and degrades gracefully (returns None) when the DB or session is missing, preserving the previous models.json fallback behavior.


Open in Devin Review

VS Code Copilot transcripts contain no model field, so git-ai always
fell back to models.json which returns the account default model
(is_chat_default == true) instead of the user-selected model.

Read the real model from VS Code's OTel SQLite DB (agent-traces.db),
querying the spans table by chat_session_id (transcript file stem),
preferring request_model over response_model, ordered by most recent
end_time_ms. The OTel lookup is inserted between transcript extraction
and the models.json fallback in the VS Code native hooks parser.
devin-ai-integration[bot]

This comment was marked as resolved.

Devin review (git-ai-project#1560): response_model was not filtered for empty
strings, so a row with NULL/empty request_model and an empty-string
response_model returned Some("") and short-circuited the models.json
fallback. Now both columns filter empty strings, consistent with the
rest of the OTel queries. Adds a regression test.
@jorgegarciarey jorgegarciarey changed the title fix(copilot): resolve VS Code model from OTel DB instead of account default fix(copilot): VS Code Copilot always reports the account default model instead of the user-selected mode Jun 15, 2026
@jorgegarciarey

Copy link
Copy Markdown
Author

@svarlamov , what do you think about this?

@svarlamov

Copy link
Copy Markdown
Member

Thank you for the contribution, @jorgegarciarey. Will do our best to review this week for an upcoming release!

@jorgegarciarey

jorgegarciarey commented Jun 22, 2026

Copy link
Copy Markdown
Author

Friendly reminder @svarlamov 👋🏼🙂

@jorgegarciarey

Copy link
Copy Markdown
Author

Hello @svarlamov . Other pull requests with this fix was opened here #1638

It seems the problem is known.

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.

[Bug]: VS Code Copilot always reports the account default model instead of the user-selected model

2 participants