Skip to content

fix: declare long-context Claude and GPT metadata - #223

Open
dgokeeffe wants to merge 2 commits into
databricks:mainfrom
dgokeeffe:fix/1m-context-claude-gpt-pi
Open

fix: declare long-context Claude and GPT metadata#223
dgokeeffe wants to merge 2 commits into
databricks:mainfrom
dgokeeffe:fix/1m-context-claude-gpt-pi

Conversation

@dgokeeffe

@dgokeeffe dgokeeffe commented Jul 18, 2026

Copy link
Copy Markdown

Summary

Fixes long-context metadata for Claude and GPT gateway models and centralizes Claude capability policy across agents.

Closes #222.

Changes

  • Pi emits explicit Claude contextWindow, maxTokens, reasoning, image, and adaptive-thinking metadata instead of accepting Pi's 128k/4k custom-model defaults.
  • Pi emits model-specific GPT limits, including the opt-in 1.05M windows for supported GPT tiers.
  • Claude family/version parsing and capability thresholds now live in one shared helper in databricks.py.
  • Pi metadata, Pi adaptive-thinking compatibility, and Claude Code's [1m] selector consume the same capability result.
  • Handles dotted, system.ai.*, databricks-*, provider-qualified, [1m]-suffixed, and future major-version IDs.
  • Opus 4.5, Haiku, and unknown models retain the conservative 200k fallback; Fable 5 uses its verified native 1M/128k capability without an added [1m] suffix.

Claude Code behavior

This PR intentionally changes Claude Code, not only Pi: Sonnet 4.5+ receives the [1m] suffix, while Opus receives it from 4.6 onward. Sonnet 4.5 has the 1M beta window with a 64k output cap. The PR description calls this out explicitly so the Claude agent behavior is reviewed as part of the change.

Review follow-up

The duplicated version policy previously split between agents/claude.py and databricks.py has been removed. Table-driven coverage now checks Opus 4.5/4.6/5, Sonnet 4.4/4.5/4.6/5, Haiku, Fable, malformed IDs, prefixes, and existing [1m] suffixes.

Validation

  • uv run pytest tests/test_databricks.py tests/test_agent_claude.py tests/test_agent_pi.py -q — passed in the final review loop
  • uv run ruff check src/ucode/databricks.py src/ucode/agents/claude.py src/ucode/agents/pi.py tests/test_databricks.py tests/test_agent_claude.py tests/test_agent_pi.py

Stacking / review scope

This PR is stacked on #217. Review the incremental commit/diff from 65b4609 to 636c3b6:

65b4609...636c3b6

After #217 merges, this branch can be rebased directly onto main.

Comment thread src/ucode/databricks.py Outdated
Comment thread src/ucode/agents/claude.py Outdated
@dgokeeffe

Copy link
Copy Markdown
Author

@rohita5l I refreshed this stacked PR: Claude capability/version policy is now shared by Pi and Claude Code, the Sonnet 4.5 Claude Code behavior is explicit in the description, and both threads have detailed replies and are resolved. Could you re-review and approve the fork CI run when convenient?

Expose the GLM and Kimi coding-model cohort through Pi and OpenCode with shared token limits and reasoning metadata. Keep unsupported chat models out of discovery, including Inkling until gateway issue databricks#215 is fixed, and retain the GPT-OSS Responses API routing guard.
Centralize Claude family/version parsing so Pi metadata, adaptive-thinking compatibility, and Claude Code's [1m] selector cannot drift. Cover Sonnet 4.5, Opus 4.6, future major versions, Fable fallback, and prefixed model IDs.
@dgokeeffe
dgokeeffe force-pushed the fix/1m-context-claude-gpt-pi branch from f2fbb83 to 636c3b6 Compare July 26, 2026 04:38
@dgokeeffe

Copy link
Copy Markdown
Author

Post-review update: shared capability policy now reflects Sonnet 4.6 at 1M/64k and Fable 5 at native 1M/128k with adaptive thinking but no [1m] suffix. GPT matching is boundary-safe/case-insensitive, excludes GPT-OSS from Responses selection, and preserves generic Responses endpoints while preferring the newest semantic GPT. PR body/comparison link updated.

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.

1M-token context not applied to Sonnet 4.5 and GPT-5 (pi)

2 participants