Skip to content

feat(core): extended thinking + bigger output budget#83

Merged
hqhq1025 merged 1 commit intomainfrom
wt/loop-feat-thinking-bigger-tokens
Apr 19, 2026
Merged

feat(core): extended thinking + bigger output budget#83
hqhq1025 merged 1 commit intomainfrom
wt/loop-feat-thinking-bigger-tokens

Conversation

@hqhq1025
Copy link
Copy Markdown
Collaborator

让模型有 10k thinking budget + 32k 输出预算,单次生成质量大幅提升(代价:时间翻 2-3 倍)。仅 Claude 4 系列启用 thinking。

Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Findings

  • [Blocker] 缺少 DCO Signed-off-by,会违反仓库硬约束并阻塞合并。证据:PR 当前提交 b630bd80eef797b0c9b9dcc5e9dd0b56f6b37e0c 的 commit message 未包含 Signed-off-by: 行。
    Suggested fix:

    git commit --amend -s --no-edit
    git push --force-with-lease
  • [Major] 将 maxTokens 无条件固定为 32000,会把所有模型都提升到同一输出上限,存在超过模型实际 max_output_tokens 导致 4xx 失败的回归风险。证据 packages/core/src/index.ts:278(无条件设置)以及默认模型目录含较小/异构模型 packages/shared/src/config.ts:97 packages/shared/src/config.ts:98 packages/shared/src/config.ts:106 packages/shared/src/config.ts:107
    Suggested fix:

    function maxTokensForModel(model: ModelRef): number | undefined {
      if (model.provider === 'anthropic' && /claude-(?:opus|sonnet)-4/i.test(model.modelId)) {
        return 32000;
      }
      return undefined; // 其他模型走 provider 默认,避免超限
    }
    
    const maxTokens = maxTokensForModel(input.model);
    result = await completeWithRetry(input.model, input.messages, {
      apiKey: input.apiKey,
      ...(maxTokens !== undefined ? { maxTokens } : {}),
      ...(reasoning !== undefined ? { reasoning } : {}),
    }, ...);

Summary

  • Review mode: initial
  • 检查范围覆盖本次最新 diff(3 files)。发现 2 个问题(1 Blocker, 1 Major)。
  • docs/VISION.mddocs/PRINCIPLES.md:Not found in repo/docs。

Testing

  • Not run (automation)

open-codesign Bot

apiKey: input.apiKey,
...(input.baseUrl !== undefined ? { baseUrl: input.baseUrl } : {}),
...(input.signal !== undefined ? { signal: input.signal } : {}),
maxTokens: MAX_OUTPUT_TOKENS,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里变成了对所有 provider/model 的硬编码上限。对于默认配置里的异构模型(例如 、),固定 32k 可能超过模型输出上限并触发 4xx。建议按模型能力分配上限,或仅对 Claude 4 开启 32k,其他模型保持 provider 默认。

Lift the per-call output budget to 32k tokens (was pi-ai's default of
~1/3 the context window, ≈10k for Opus 4) and ask Claude 4.x models to
"think before answering" via pi-ai's reasoning='high' knob, which the
Anthropic adapter maps to extended thinking. Non-Anthropic / pre-4
models keep their default reasoning behaviour but still benefit from
the larger output budget.
@hqhq1025 hqhq1025 force-pushed the wt/loop-feat-thinking-bigger-tokens branch from b630bd8 to 7bf6e61 Compare April 19, 2026 05:17
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Findings

  • [Blocker] 缺少 DCO Signed-off-by,会违反仓库硬约束并阻塞合并。证据:当前提交 7bf6e6108de2cb6168b19c7d1ff9cbe1082c7df8 的 commit message 未包含 Signed-off-by: 行。
    Suggested fix:

    git commit --amend -s --no-edit
    git push --force-with-lease
  • [Major] maxTokens 被无条件固定为 32000,会把所有 provider/model 都推到同一输出上限;对较小输出上限模型会触发 provider 4xx 并导致生成失败。证据 packages/core/src/index.ts:291,且该行为被测试固化 packages/core/src/generate.test.ts:132
    Suggested fix:

    function maxTokensForModel(model: ModelRef): number | undefined {
      if (model.provider === 'anthropic' && /claude-(?:opus|sonnet)-4/i.test(model.modelId)) {
        return 32000;
      }
      return undefined; // 其他模型走 provider 默认,避免超限
    }
    
    const maxTokens = maxTokensForModel(input.model);
    result = await completeWithRetry(input.model, input.messages, {
      apiKey: input.apiKey,
      ...(maxTokens !== undefined ? { maxTokens } : {}),
      ...(reasoning !== undefined ? { reasoning } : {}),
    }, ...);

Summary

  • Review mode: follow-up after new commits
  • 本次最新 diff(3 files)仍有 2 个问题(1 Blocker, 1 Major)。
  • docs/VISION.mddocs/PRINCIPLES.md: Not found in repo/docs.

Testing

  • Not run (automation)

open-codesign Bot

apiKey: input.apiKey,
...(input.baseUrl !== undefined ? { baseUrl: input.baseUrl } : {}),
...(input.signal !== undefined ? { signal: input.signal } : {}),
maxTokens: MAX_OUTPUT_TOKENS,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里对所有模型无条件传 maxTokens: 32000。这会把 OpenAI/Groq/部分 OpenRouter 小模型也抬到 32k,上游若不支持会直接 4xx。建议仅对已确认支持的 Claude 4.x 设 32k,其它模型保持 provider 默认。

@hqhq1025 hqhq1025 merged commit 2368267 into main Apr 19, 2026
5 of 6 checks passed
@hqhq1025 hqhq1025 deleted the wt/loop-feat-thinking-bigger-tokens branch April 19, 2026 05:23
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