Skip to content

fix(catalog): read GitHub Copilot context window metadata - #3163

Merged
lidge-jun merged 1 commit into
devfrom
ingw/fix-copilot-context-3156
Sep 1, 2026
Merged

lidge-jun merged 1 commit into
devfrom
ingw/fix-copilot-context-3156

Conversation

@Ingwannu

@Ingwannu Ingwannu commented Sep 1, 2026

Copy link
Copy Markdown
Owner

Summary

  • read GitHub Copilot's live context-window field at capabilities.limits.max_context_window_tokens
  • preserve the existing metadata precedence when both old and Copilot-shaped fields are present
  • reject malformed/non-positive values through the existing safe-integer boundary
  • add an end-to-end routed catalog regression for accepted, conflicting, and invalid Copilot payloads

Root cause

The live-model parser recognized metadata.limits.max_context_length, metadata.context_length, and top-level compatibility fields, but GitHub Copilot publishes the value under capabilities.limits.max_context_window_tokens. The value was therefore lost before catalog construction and Codex fell back to the conservative 128K window.

Verification

Exact head 486b2f99f3182acf055274755ade9c6571203ac9:

  • focused Copilot regression: 1 passed, 0 failed
  • bun test tests/codex-catalog.test.ts: 255 passed, 0 failed
  • bun run typecheck: this branch and an unmodified dev worktree both report the same three pre-existing fetch(..., { timeout }) type errors in src/server/claude-messages.ts and src/server/responses/fetch-helpers.ts; this diff adds no type errors
  • all local runs used isolated HOME, OPENCODEX_HOME, and CODEX_HOME, nice -n 10, and a two-CPU affinity

Full exact-head CI is still required before merge.

Closes #3156.

Summary by CodeRabbit

  • Bug Fixes
    • Improved live model discovery for GitHub Copilot by recognizing context-window limits reported through capabilities.
    • Preserved explicitly configured context-window values when they differ from live discovery data.
    • Ignored invalid negative context-window values.

@Ingwannu
Ingwannu requested a review from lidge-jun as a code owner September 1, 2026 15:27
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Deterministic PR hygiene checks passed.

@coderabbitai

coderabbitai Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Team

Run ID: 6af26e8b-ef8d-48d7-8555-9791fe549f78

📥 Commits

Reviewing files that changed from the base of the PR and between 7ac4c9f and 486b2f9.

📒 Files selected for processing (2)
  • src/codex/catalog/provider-fetch.ts
  • tests/codex-catalog.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The catalog parser reads capabilities.limits.max_context_window_tokens as a fallback context window for Copilot models. Tests verify fallback resolution, metadata precedence, and rejection of negative values.

Changes

Copilot context window discovery

Layer / File(s) Summary
Context window fallback and validation
src/codex/catalog/provider-fetch.ts:1198-1206, tests/codex-catalog.test.ts:5369-5411
catalogHintsFromModelsApiItem uses capabilities.limits.max_context_window_tokens after limits.max_context_length. Tests verify the 1M capability value, 256k metadata precedence, and rejection of a negative value.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 486b2

The PR adds support for GitHub Copilot context-window metadata while preserving existing precedence and validation behavior; no actionable merge-blocking risk remains after normal checks and review.

Suggested reviewers: lidge-j

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the primary change: reading GitHub Copilot context-window metadata in the catalog parser.
Linked Issues check ✅ Passed The changes satisfy issue #3156. src/codex/catalog/provider-fetch.ts reads capabilities.limits.max_context_window_tokens as a fallback, while preserving metadata.limits.max_context_length precedence a…
Out of Scope Changes check ✅ Passed The changes are limited to the requested Copilot context-window parsing fix and regression tests. No unrelated code or behavior changes are present in the provided summary.
Full details: Linked Issues check

Explanation

The changes satisfy issue #3156. src/codex/catalog/provider-fetch.ts reads capabilities.limits.max_context_window_tokens as a fallback, while preserving metadata.limits.max_context_length precedence and safe-integer validation. tests/codex-catalog.test.ts covers valid, conflicting, and invalid Copilot payloads.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ingw/fix-copilot-context-3156

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@lidge-jun
lidge-jun merged commit e236c36 into dev Sep 1, 2026
27 checks passed
@lidge-jun
lidge-jun deleted the ingw/fix-copilot-context-3156 branch September 1, 2026 16:04
@lidge-jun

Copy link
Copy Markdown
Owner

리뷰 · 우선순위 67 / 80

설명

이 PR은 이슈 #3156을 고칩니다. GitHub Copilot 라이브 모델 페이로드가 context window를 capabilities.limits.max_context_window_tokens 에 두는데, OpenCodex 카탈로그 파서가 그 필드를 읽지 않아 Codex /status 가 보수적 128k로 떨어지던 구멍입니다. 패치는 그 필드를 읽고, 예전 metadata 필드와 같이 있으면 기존 우선순위를 유지하며, 비정상·비양수 값은 기존 positiveSafeInteger 경계로 버립니다. 수락·충돌·무효 Copilot 페이로드 회귀를 tests/codex-catalog.test.ts 에 넣습니다.

지금 HEAD src/codex/catalog/provider-fetch.tscatalogHintsFromModelsApiItemmetadata.limits.max_context_length, metadata.context_length, top-level context_length/context_size/max_model_len/max_context_length, llama.cpp meta.n_ctx 만 모읍니다. Copilot 경로는 없습니다. #2943/#2944 가 nested supports.vision 은 읽게 했지만 context window 필드명은 다른 축입니다. 이 PR diff는 plainRecord(item.capabilities)?.limits 를 후보에 추가합니다. +49/−0, MERGEABLE, 브랜치 ingw/fix-copilot-context-3156 입니다.

typecheck의 기존 fetch(..., { timeout }) 세 오류는 이 diff와 무관하다고 본문이 적습니다. types.ts/config.ts 분할 캠페인과 무관합니다. remote hub 열차와 파일도 겹치지 않아 독립 랜딩하기 좋습니다. 모델마다 16k~1M 창이 128k로 보이면 사용자가 컨텍스트를 잘못 자릅니다.

점수는 67입니다. 작은 카탈로그 정확도 수정이고 #3156과 1:1입니다.

라인 src/codex/catalog/provider-fetch.ts contextWindow 후보 목록 - Copilot 필드를 기존 metadata 후보보다 뒤에 두어 "둘 다 있으면 예전 필드 우선"이 되어야 본문과 같습니다
라인 tests/codex-catalog.test.ts Copilot 회귀 - routed catalog end-to-end가 실제 catalogHintsFromModelsApiItem 을 타는지 확인하십시오
경로 issue #3156 - 머지 시 이슈를 닫으십시오. Closes 링크를 확인합니다
경로 #2943/#2944 - vision과 한 changelog에 적어도, 이 PR 범위에는 넣지 마십시오
경로 positiveSafeInteger - 0/음수/비숫자는 창을 만들지 않아 128k 폴백이 남습니다. 그게 안전 기본입니다

메인테이너의 판단이 필요한 지점

  • capabilities.limits를 전 제공자에 열어 두어도 되는지(양수 정수만 받으므로 대체로 안전)
  • 2.40.0 릴리스 노트에 Copilot context window 한 줄을 넣을지

너의 추천
머지하고 #3156을 닫습니다. 작은 독립 버그픽스입니다. 라벨은 바꾸지 않습니다.

이 댓글은 grok-bot이 작성했습니다

lidge-jun pushed a commit that referenced this pull request Sep 1, 2026
lidge-jun pushed a commit that referenced this pull request Sep 1, 2026
lidge-jun pushed a commit that referenced this pull request Sep 2, 2026
lidge-jun pushed a commit that referenced this pull request Sep 2, 2026
lidge-jun added a commit that referenced this pull request Sep 2, 2026
…sion audit (#3218)

* docs(devlog): open the bug/PR closeout stack roadmap

* docs(devlog): fold the A-gate import-boundary finding into phase 5

* docs(devlog): record the #3163 and #3166 landings

* docs(devlog): record why #2986 does not land in this train

* docs(devlog): close out the bug/PR closeout stack

* docs(devlog): record the final green CI verdict on dev

* docs(devlog): open the bug-label drawdown roadmap with audit corrections

* docs(devlog): record the Batch A landings and first rebase carry

* docs(devlog): record the Batch B rebase carries

* docs(devlog): record why the rebase service earned its keep

* docs(devlog): record the Batch C rebases and the one real review finding

* docs(devlog): record the #2999 scope boundary that survived execution

* docs(devlog): record Batch D - every bug PR closed

* docs(devlog): record what the PR half of the campaign cost

* docs(devlog): replan the remaining issues to one per cycle

* docs(devlog): carry the i3141 evidence into the replan

* docs(devlog): diagnose i3141 - fix predates the reported version

* docs(devlog): retire the second bundle

* docs(devlog): record the i3141 re-triage action and outcome

* docs(devlog): diagnose i3152 log table jitter

* docs(devlog): i3152 - measurement disproved the layout diagnosis

* docs(devlog): diagnose i3136 slashed-id price lookup

* docs(devlog): diagnose i3150 citation marker passthrough

* docs(devlog): diagnose i3155 capacity plan allowlist

* docs(devlog): i1419 stays open pending crash frames

* docs(devlog): record the i1419 re-triage ask

* docs(devlog): diagnose i2999 publication overwrite race

* docs(devlog): record the i2999 outcome and remaining scope

* docs(devlog): diagnose i2813 as a client-side reserve gate

* docs(devlog): diagnose i1527 residuals as trace-blocked

* docs(devlog): correct i1527 envelope-cap wording (192 blobs, HTTP 400)

* docs(devlog): plan p3193 loopback alpha-search reimplementation

* docs(devlog): record p3193 landing (#3205 -> 53c09a2)

* docs(devlog): plan the main->dev regression audit

* docs(devlog): pin regaudit counts, add tests-only/security passes and the exact-head dispatch

* docs(devlog): record regaudit reviewer verdicts

* docs(devlog): record the exact-head dev CI verdict and Windows classification

* docs(devlog): record the main control run proving the Windows failures predate the range

* docs(devlog): record the pass-1 recount and the #3217 root cause

* docs(devlog): plan i3217 (Spark functions-namespace flattening)

* docs(devlog): record i3217 landing (#3224 -> d23eab4)

* docs(devlog): regaudit2 recount and disposition table

* docs(devlog): regaudit2 CI verdict on d23eab4 and the four PR arrivals

* docs(devlog): plan p3226 (scoped namespace scrub)

* docs(devlog): p3226 audit finding and carry plan

* docs(devlog): record p3226 landing (#3234 -> b732b0d)

* docs(devlog): plan p3227 (combo zero-output incomplete failover)

* docs(devlog): record p3227 landing

* docs(devlog): plan p3228 (encrypted V2 spawn native fallback)

* docs(devlog): record p3228 landing

* docs(devlog): plan p3229 (Codexless originator in task recovery)

* docs(devlog): record p3229 landing and the #3239 regression repair

* docs(devlog): r3239 regression repair record

* docs(devlog): r3239 audit note

* docs(devlog): record p3232 (merged by maintainer)

* docs(devlog): p3232 verification result

* docs(devlog): regaudit3 recount and landing table

* docs(devlog): record the #3239/#3240 revert and correct the #3228 disposition

* docs(devlog): rv3239 revert record

* docs(devlog): rv3239 audit note

* docs(devlog): regaudit3 second-dispatch verdict

* docs(devlog): regaudit3 recount refreshed (#1419 closed by maintainer; count 4)

* docs(devlog): regaudit3 final CI verdict and c-7

---------

Co-authored-by: jun <jun@lidge.dev>
tarunravi pushed a commit to tarunravi/opencodex that referenced this pull request Sep 14, 2026
Co-authored-by: Ingwannu <ingwannu@users.noreply.github.com>
tarunravi pushed a commit to tarunravi/opencodex that referenced this pull request Sep 14, 2026
…sion audit (lidge-jun#3218)

* docs(devlog): open the bug/PR closeout stack roadmap

* docs(devlog): fold the A-gate import-boundary finding into phase 5

* docs(devlog): record the lidge-jun#3163 and lidge-jun#3166 landings

* docs(devlog): record why lidge-jun#2986 does not land in this train

* docs(devlog): close out the bug/PR closeout stack

* docs(devlog): record the final green CI verdict on dev

* docs(devlog): open the bug-label drawdown roadmap with audit corrections

* docs(devlog): record the Batch A landings and first rebase carry

* docs(devlog): record the Batch B rebase carries

* docs(devlog): record why the rebase service earned its keep

* docs(devlog): record the Batch C rebases and the one real review finding

* docs(devlog): record the lidge-jun#2999 scope boundary that survived execution

* docs(devlog): record Batch D - every bug PR closed

* docs(devlog): record what the PR half of the campaign cost

* docs(devlog): replan the remaining issues to one per cycle

* docs(devlog): carry the i3141 evidence into the replan

* docs(devlog): diagnose i3141 - fix predates the reported version

* docs(devlog): retire the second bundle

* docs(devlog): record the i3141 re-triage action and outcome

* docs(devlog): diagnose i3152 log table jitter

* docs(devlog): i3152 - measurement disproved the layout diagnosis

* docs(devlog): diagnose i3136 slashed-id price lookup

* docs(devlog): diagnose i3150 citation marker passthrough

* docs(devlog): diagnose i3155 capacity plan allowlist

* docs(devlog): i1419 stays open pending crash frames

* docs(devlog): record the i1419 re-triage ask

* docs(devlog): diagnose i2999 publication overwrite race

* docs(devlog): record the i2999 outcome and remaining scope

* docs(devlog): diagnose i2813 as a client-side reserve gate

* docs(devlog): diagnose i1527 residuals as trace-blocked

* docs(devlog): correct i1527 envelope-cap wording (192 blobs, HTTP 400)

* docs(devlog): plan p3193 loopback alpha-search reimplementation

* docs(devlog): record p3193 landing (lidge-jun#3205 -> 53c09a2)

* docs(devlog): plan the main->dev regression audit

* docs(devlog): pin regaudit counts, add tests-only/security passes and the exact-head dispatch

* docs(devlog): record regaudit reviewer verdicts

* docs(devlog): record the exact-head dev CI verdict and Windows classification

* docs(devlog): record the main control run proving the Windows failures predate the range

* docs(devlog): record the pass-1 recount and the lidge-jun#3217 root cause

* docs(devlog): plan i3217 (Spark functions-namespace flattening)

* docs(devlog): record i3217 landing (lidge-jun#3224 -> d23eab4)

* docs(devlog): regaudit2 recount and disposition table

* docs(devlog): regaudit2 CI verdict on d23eab4 and the four PR arrivals

* docs(devlog): plan p3226 (scoped namespace scrub)

* docs(devlog): p3226 audit finding and carry plan

* docs(devlog): record p3226 landing (lidge-jun#3234 -> b732b0d)

* docs(devlog): plan p3227 (combo zero-output incomplete failover)

* docs(devlog): record p3227 landing

* docs(devlog): plan p3228 (encrypted V2 spawn native fallback)

* docs(devlog): record p3228 landing

* docs(devlog): plan p3229 (Codexless originator in task recovery)

* docs(devlog): record p3229 landing and the lidge-jun#3239 regression repair

* docs(devlog): r3239 regression repair record

* docs(devlog): r3239 audit note

* docs(devlog): record p3232 (merged by maintainer)

* docs(devlog): p3232 verification result

* docs(devlog): regaudit3 recount and landing table

* docs(devlog): record the lidge-jun#3239/lidge-jun#3240 revert and correct the lidge-jun#3228 disposition

* docs(devlog): rv3239 revert record

* docs(devlog): rv3239 audit note

* docs(devlog): regaudit3 second-dispatch verdict

* docs(devlog): regaudit3 recount refreshed (lidge-jun#1419 closed by maintainer; count 4)

* docs(devlog): regaudit3 final CI verdict and c-7

---------

Co-authored-by: jun <jun@lidge.dev>
agentHits pushed a commit to agentHits/opencodex that referenced this pull request Sep 17, 2026
Co-authored-by: Ingwannu <ingwannu@users.noreply.github.com>
agentHits pushed a commit to agentHits/opencodex that referenced this pull request Sep 17, 2026
…sion audit (lidge-jun#3218)

* docs(devlog): open the bug/PR closeout stack roadmap

* docs(devlog): fold the A-gate import-boundary finding into phase 5

* docs(devlog): record the lidge-jun#3163 and lidge-jun#3166 landings

* docs(devlog): record why lidge-jun#2986 does not land in this train

* docs(devlog): close out the bug/PR closeout stack

* docs(devlog): record the final green CI verdict on dev

* docs(devlog): open the bug-label drawdown roadmap with audit corrections

* docs(devlog): record the Batch A landings and first rebase carry

* docs(devlog): record the Batch B rebase carries

* docs(devlog): record why the rebase service earned its keep

* docs(devlog): record the Batch C rebases and the one real review finding

* docs(devlog): record the lidge-jun#2999 scope boundary that survived execution

* docs(devlog): record Batch D - every bug PR closed

* docs(devlog): record what the PR half of the campaign cost

* docs(devlog): replan the remaining issues to one per cycle

* docs(devlog): carry the i3141 evidence into the replan

* docs(devlog): diagnose i3141 - fix predates the reported version

* docs(devlog): retire the second bundle

* docs(devlog): record the i3141 re-triage action and outcome

* docs(devlog): diagnose i3152 log table jitter

* docs(devlog): i3152 - measurement disproved the layout diagnosis

* docs(devlog): diagnose i3136 slashed-id price lookup

* docs(devlog): diagnose i3150 citation marker passthrough

* docs(devlog): diagnose i3155 capacity plan allowlist

* docs(devlog): i1419 stays open pending crash frames

* docs(devlog): record the i1419 re-triage ask

* docs(devlog): diagnose i2999 publication overwrite race

* docs(devlog): record the i2999 outcome and remaining scope

* docs(devlog): diagnose i2813 as a client-side reserve gate

* docs(devlog): diagnose i1527 residuals as trace-blocked

* docs(devlog): correct i1527 envelope-cap wording (192 blobs, HTTP 400)

* docs(devlog): plan p3193 loopback alpha-search reimplementation

* docs(devlog): record p3193 landing (lidge-jun#3205 -> 144ddf4)

* docs(devlog): plan the main->dev regression audit

* docs(devlog): pin regaudit counts, add tests-only/security passes and the exact-head dispatch

* docs(devlog): record regaudit reviewer verdicts

* docs(devlog): record the exact-head dev CI verdict and Windows classification

* docs(devlog): record the main control run proving the Windows failures predate the range

* docs(devlog): record the pass-1 recount and the lidge-jun#3217 root cause

* docs(devlog): plan i3217 (Spark functions-namespace flattening)

* docs(devlog): record i3217 landing (lidge-jun#3224 -> fe855b3)

* docs(devlog): regaudit2 recount and disposition table

* docs(devlog): regaudit2 CI verdict on fe855b3 and the four PR arrivals

* docs(devlog): plan p3226 (scoped namespace scrub)

* docs(devlog): p3226 audit finding and carry plan

* docs(devlog): record p3226 landing (lidge-jun#3234 -> 827456e)

* docs(devlog): plan p3227 (combo zero-output incomplete failover)

* docs(devlog): record p3227 landing

* docs(devlog): plan p3228 (encrypted V2 spawn native fallback)

* docs(devlog): record p3228 landing

* docs(devlog): plan p3229 (Codexless originator in task recovery)

* docs(devlog): record p3229 landing and the lidge-jun#3239 regression repair

* docs(devlog): r3239 regression repair record

* docs(devlog): r3239 audit note

* docs(devlog): record p3232 (merged by maintainer)

* docs(devlog): p3232 verification result

* docs(devlog): regaudit3 recount and landing table

* docs(devlog): record the lidge-jun#3239/lidge-jun#3240 revert and correct the lidge-jun#3228 disposition

* docs(devlog): rv3239 revert record

* docs(devlog): rv3239 audit note

* docs(devlog): regaudit3 second-dispatch verdict

* docs(devlog): regaudit3 recount refreshed (lidge-jun#1419 closed by maintainer; count 4)

* docs(devlog): regaudit3 final CI verdict and c-7

---------

Co-authored-by: jun <jun@lidge.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants