Skip to content

fix: centralize Claude and GPT context capabilities - #333

Open
dgokeeffe wants to merge 2 commits into
databricks:mainfrom
dgokeeffe:review/shared-context-policy
Open

fix: centralize Claude and GPT context capabilities#333
dgokeeffe wants to merge 2 commits into
databricks:mainfrom
dgokeeffe:review/shared-context-policy

Conversation

@dgokeeffe

Copy link
Copy Markdown

Issue and stack

Closes #222.

Depends on #217. GitHub must target main for fork PRs; review the concern-isolated incremental range:

dgokeeffe/ucode@036572c...f299e50

Do not merge before #217. After #217 merges, the visible PR diff collapses to this six-file context-policy unit.


Unit 03 — shared Claude/GPT context capability policy

Objective and user-visible behavior

Centralize Claude family/version capabilities and GPT token windows so Pi does not truncate custom gateway models to small defaults and Claude Code applies the 1M selector consistently.

Candidate: review/shared-context-policy (f299e50), mandatory PR target review/oss-base (036572c), existing PR #223 after unit 02 is separated.

Exact scope

Production: src/ucode/databricks.py, src/ucode/agents/claude.py, src/ucode/agents/pi.py.
Tests: tests/test_databricks.py, tests/test_agent_claude.py, tests/test_agent_pi.py.
Non-goals: GPT off-thinking mapping, OpenCode routing, dynamic OSS discovery, proxying, cache retention.

Before / after reproduction

git show 036572c:src/ucode/agents/claude.py | rg 'claude_model_supports_1m'
# no match

git show review/shared-context-policy:src/ucode/agents/claude.py | rg 'claude_model_supports_1m'
# shared helper import and call are present

Focused validation:

uv run --frozen pytest tests/test_databricks.py tests/test_agent_claude.py tests/test_agent_pi.py -q
# 371 passed
uv run --frozen ruff check .
# All checks passed

Full suite:

uv run --frozen pytest -q
# 2 failed, 1614 passed, 36 skipped

Only installed Claude/Pi capture tests fail on this older stack. Unit 01/integrated dev resolves the Pi path isolation case; integrated dev independently reproduces the Claude capture failure.

Capability evidence

Table-driven tests cover dotted, system.ai.*, databricks-*, provider-qualified, [1m]-suffixed, malformed, and future-major IDs. Verified policy includes GPT-5.6 Sol/Terra/Luna 1.05M windows, model-specific GPT fallbacks, Claude Opus 4.6+, Sonnet 4.5+, Fable 5, Haiku, and conservative unknown-model behavior. No credentials or endpoint identifiers are recorded.

Impact map

  • Agents: Claude Code and Pi.
  • Providers: Anthropic and OpenAI Responses metadata only.
  • Config: Pi model entries gain explicit contextWindow, maxTokens, reasoning/image metadata; Claude selector may gain [1m] only from shared policy.
  • Compatibility: conservative 200k Claude fallback and bounded GPT fallback reduce unknown-ID risk.
  • Managed config/MCP/skills: model IDs flow through existing paths; no state or registration schema changes.

Rollback and residual risk

Revert f299e50; this restores duplicated policy and Pi's smaller custom-model defaults. Residual risk is provider capability evolution; update the centralized table and table-driven tests together.

Hygiene

git diff --check review/oss-base..review/shared-context-policy passes. PR #223 must target the OSS base; its target-relative diff is the review contract. Six-file range; no generated files, credentials, uv.lock, .pi-subagents/, or goal.md; no merge markers or unresolved index entries.

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.
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)

1 participant