fix: declare long-context Claude and GPT metadata - #223
Conversation
a6359d3 to
9e6b87d
Compare
9e6b87d to
f2fbb83
Compare
|
@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? |
f2fbb83 to
636c3b6
Compare
|
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 |
|
Pushed
else if (model.provider !== "github-copilot" && model.thinkingLevelMap?.off !== null) {
params.reasoning = { effort: (model.thinkingLevelMap?.off ?? "none") };
}
Measured against
Fix is Also bisected the rest of Pi's Responses payload against the gateway; all 200, no other compat flags needed: Added two regression tests in
Two things for reviewers:
Worth noting this was painful to diagnose because the gateway returns |
8d66253 to
15ad5c0
Compare
|
Rebased this PR stack onto current Stack dependencyThis is 2 of 3 and must land after #217:
The rebase preserves main's #282 contract: Pi pins
If #217 is squash-merged, please rebase this branch onto the updated Validation
Managed allowlist × live-discovery intersection is deliberately outside this PR and tracked in #290. |
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.
`_pi_gpt_model_entry` declared `reasoning: True` without an off-state, so for
the thinking-off case Pi's Responses builder fell back to
`reasoning: {effort: "none"}` (pi-ai openai-responses.js, the
`thinkingLevelMap?.off !== null` branch). `"none"` is only valid on gpt-5.1+,
so every request to gpt-5, gpt-5-mini, gpt-5-nano and gpt-5-5-pro was rejected:
BAD_REQUEST: Unsupported value: 'none' is not supported with the 'gpt-5'
model. Supported values are: 'minimal', 'low', 'medium', and 'high'.
Setting `thinkingLevelMap: {"off": None}` makes Pi omit `reasoning` entirely,
which the gateway accepts for all 14 codex ids. Verified against
/ai-gateway/codex/v1/responses: effort="none" 400s on gpt-5/-mini/-nano/-5-5-pro
and 200s on gpt-5-1..-5-6; omitting `reasoning` is 200 everywhere.
`{"off": "minimal"}` was rejected as an alternative because gpt-5-5-pro 400s on
it too. Same pattern already used for the Gemini 3.x entries.
The rest of Pi's Responses payload was bisected against the gateway and is
fine: store:false, prompt_cache_key, prompt_cache_retention:"24h",
prompt_cache_options, include:["reasoning.encrypted_content"], developer role,
flat tool schemas, and the session_id / x-client-request-id affinity headers.
Regression was hard to spot because the gateway returns
{"error_code","message"} rather than OpenAI's {"error":...}, so Pi's
error-body.js recovery no-ops and every 400 renders as
"OpenAI API error (400): 400 status code (no body)". Reported upstream as
earendil-works/pi#7748.
Refs databricks#286
15ad5c0 to
94fe107
Compare
Summary
Fixes long-context metadata for Claude and GPT gateway models and centralizes Claude capability policy across agents.
Closes #222.
Changes
contextWindow,maxTokens, reasoning, image, and adaptive-thinking metadata instead of accepting Pi's 128k/4k custom-model defaults.databricks.py.[1m]selector consume the same capability result.system.ai.*,databricks-*, provider-qualified,[1m]-suffixed, and future major-version IDs.[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.pyanddatabricks.pyhas 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 loopuv 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.pyStacking / review scope
This PR is stacked on #217. Review the incremental commit/diff from
65b4609to636c3b6:65b4609...636c3b6
After #217 merges, this branch can be rebased directly onto
main.