feat(catalog): 站内模型能力表,修复 Pi 思考等级静默失效与上下文窗口缺省 - #8
Merged
Conversation
Pi 生成的 models.json 此前只有裸 id,Pi 将所有模型视为非推理模型, 思考等级静默失效(issue #7);各 Harness 的上下文窗口也回落到 ~128K 默认值。 - 新增 src/model-catalog.ts:按网关模型 id 收录 reasoning/contextWindow/ maxTokens 与 Pi 语义的 compat/thinkingLevelMap,数据以 Pi 官方目录为基准, 按网关实际转发行为修正(Claude/Gemini 通道仅认 reasoning_effort low/medium/high,高档位收敛映射到 high) - Pi 适配器输出完整元数据;OpenCode 补 limit.context/output 与 reasoning; OpenClaw 补 contextWindow/maxTokens/reasoning - 未知模型 id 保持最小条目回退,不阻塞选择 Fixes #7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
Fixes #7 ——
init写给 Pi 的models.json只有裸{id},Pi 将全部模型视为非推理模型,--model xxx:high/会话内切档静默无效;同时各 Harness 拿不到上下文窗口,普遍回落到 ~128K 默认值。方案
新增
src/model-catalog.ts:覆盖网关当前在售全部 35 个模型(以生产/v1/models实际清单为准),每条含reasoning/contextWindow/maxTokens,推理模型另带 Pi 语义的compat(thinkingFormat/supportsReasoningEffort等)与thinkingLevelMap。数据基准与网关修正:
reasoning_effortlow/medium/high 映射为 thinking budget(1280/2048/4096),其余档位直接忽略 → 表内 xhigh/max 收敛映射到 high,minimal 置 null;reasoning_effortminimal/low/medium/high → thinkingBudget 百分比钳制 → 同理收敛;qwen3.8-max条目与 issue Pi: generated models.json lacks reasoning metadata, thinking level silently broken for all models #7 中本地验证过的修复完全一致。适配器接入:
limit.context/output+reasoning(models.dev schema);contextWindow/maxTokens/reasoning(types.models.ts 已支持的字段,不写 Pi 专有字段);待议(不阻塞本 PR)
zaiToolStream: true(该开关影响 Pi 对 z.ai 流式 tool call 的解析;经网关转发后行为未实测,如 GLM 工具调用异常再补);验证
bun test:134 pass / 0 fail(新增 catalog 覆盖与不变量测试 + 三个适配器的元数据测试,TDD 先红后绿);bun run build通过;tsc --noEmit的 bun-types 报错在 main 上同样存在,与本 PR 无关。