Skip to content

Conversation

@kazuhitogo
Copy link
Collaborator

@kazuhitogo kazuhitogo commented Oct 3, 2025

Description of Changes

Extended Thinking を行うためには Output Token を追加で使う必要があり、今までの実装では、Extended Thinking の Budget Token を MaxTokens に追加(足し算)する仕様であった。
しかし、Sonnet 4.5 対応時に最初から MaxTokens を最大値の 64000 に設定していたため、足し算を行うと必ず不正な値(>64000)になり extended thinking を使うと必ずエラーが起きていた。

今まで足し算にしていた理由として、LLM が過去に repetition 等を起こしてトークンを浪費してしまうケースがあった。昨今の LLM に repetition が見られなくなってきたため、足し算の処理をやめ、最初からモデルの最大トークンを設定するように修正する。

Checklist

  • [-] Modified relevant documentation
  • Verified operation in local environment
  • Executed npm run cdk:test and if there are snapshot differences, execute npm run cdk:test:update-snapshot to update snapshots

Related Issues

#1297


// Model Params
const CLAUDE_4_5_DEFAULT_PARAMS: ConverseInferenceParams = {
const CLAUDE_SONNET_4_DEFAULT_PARAMS: ConverseInferenceParams = {
Copy link
Collaborator Author

@kazuhitogo kazuhitogo Oct 3, 2025

Choose a reason for hiding this comment

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

もともと 4.5 用に作っていたものですが、sonnet 4 系(と例外で3.7)としてまとめられるのでこの表記に変えました。

const CLAUDE_OPUS_4_DEFAULT_PARAMS: ConverseInferenceParams = {
inferenceConfig: {
maxTokens: 32000,
temperature: 1,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

マネジメントコンソールのデフォルト値かつ、最近のLLMはTemperature及びTopPを最大化する傾向(ベンチマーク時に高目に設定してそれで精度が出ている)にあるので、高い数値を設定しています。

@kazuhitogo kazuhitogo changed the title Extended Thinking を Sonnet 4.5 でも使えるようにする [WIP]Extended Thinking を Sonnet 4.5 でも使えるようにする Oct 3, 2025
@kazuhitogo kazuhitogo changed the title [WIP]Extended Thinking を Sonnet 4.5 でも使えるようにする Extended Thinking を Sonnet 4.5 でも使えるようにする Oct 3, 2025
Copy link
Collaborator

@Calic0Cat Calic0Cat left a comment

Choose a reason for hiding this comment

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

LGTMです。動作確認できました。

@Calic0Cat Calic0Cat merged commit d19fb4a into main Oct 3, 2025
6 checks passed
@kazuhitogo kazuhitogo deleted the fix/claude-4-5-token-budget branch October 3, 2025 05:47
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.

2 participants