Skip to content

fix: unlock 1M-token context for Sonnet 4.5 and GPT-5 in pi#1

Closed
dgokeeffe wants to merge 1 commit into
feat/pi-oss-provider-v2from
fix/1m-context-claude-gpt-pi
Closed

fix: unlock 1M-token context for Sonnet 4.5 and GPT-5 in pi#1
dgokeeffe wants to merge 1 commit into
feat/pi-oss-provider-v2from
fix/1m-context-claude-gpt-pi

Conversation

@dgokeeffe

@dgokeeffe dgokeeffe commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes long-context metadata for Claude and GPT gateway models, with GPT handling scoped to Pi.

  • Claude Code: add [1m] to Sonnet 4.5+ and Opus 4.6+ aliases.
  • Pi: emit explicit Claude contextWindow, maxTokens, reasoning, image, and adaptive-thinking metadata instead of accepting Pi's custom-model defaults.
  • Pi: emit model-specific GPT limits; GPT-5.6 Sol/Terra/Luna use the opt-in 1,050,000-token window rather than treating every GPT-5 model as 1M.
  • Handle dotted, system.ai.*, databricks-*, and provider-qualified model IDs.

Closes databricks#222.

Root cause and reproducible proof

Pi 0.80.6 documents these defaults for custom models when fields are omitted:

contextWindow: 128000
maxTokens: 4096

ucode previously emitted Claude models as only {"id": ...}, so Pi displayed and compacted Opus 4.8 as a 128K model even though the gateway model is long-context.

The installed Pi catalog independently declares Claude Opus 4.8 as:

contextWindow: 1000000
maxTokens: 128000

Pi's model override docs also explicitly show GPT-5.6 Sol can opt into:

{"gpt-5.6-sol": {"contextWindow": 1050000}}

After this patch, rendering a ucode Pi overlay produces:

{
  "id": "databricks-claude-opus-4-8",
  "reasoning": true,
  "input": ["text", "image"],
  "contextWindow": 1000000,
  "maxTokens": 128000,
  "compat": {"forceAdaptiveThinking": true}
}

and:

{
  "id": "databricks-gpt-5-6-sol",
  "contextWindow": 1050000,
  "maxTokens": 128000,
  "reasoning": true,
  "input": ["text", "image"]
}

Claude Code 2.1.214 bundle inspection also confirms that [1m] selects context-1m-2025-08-07 independently of CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS. Therefore beta suppression was not the root cause of Pi's 128K display; the omitted Pi custom-model metadata was.

Validation

uv run pytest tests/test_agent_pi.py tests/test_databricks.py tests/test_agent_claude.py tests/test_lint.py -q
272 passed in 5.53s

uv run ruff check .
All checks passed!

A full local run reached 913 passed, 36 skipped; its only behavioral failure was the managed-environment Claude binary timing out before reaching the test capture server. The other failure was formatting, subsequently fixed and covered by the passing tests/test_lint.py run above.

Stacking

This PR is stacked on dgokeeffe:feat/pi-oss-provider-v2 / databricks#217. Retarget to databricks/ucode:main after databricks#217 merges.

@dgokeeffe
dgokeeffe force-pushed the fix/1m-context-claude-gpt-pi branch from 2b16fcc to a6359d3 Compare July 18, 2026 13:15
@dgokeeffe

Copy link
Copy Markdown
Owner Author

Superseded by upstream PR: databricks#223

@dgokeeffe dgokeeffe closed this Jul 18, 2026
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.

1 participant