0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Amazon Bedrock の OpenAI モデルで推論の要約(reasoning summary)が取れるようになったので試してみた

0
Posted at

はじめに

Amazon Bedrock の OpenAI モデルで、推論の要約(reasoning summary) が返せるようになりました。

GPT-5.6 のような推論モデルは、回答する前に内部で「考える」ステップを踏みます。ただしその中身はレスポンスに含まれず、返るのは暗号化された encrypted_content だけなので、モデルがどう考えてその答えにしたのかは読めませんでした。今回のアップデートで、その考えた過程を人が読める要約として受け取れるようになりました。

推論の本体はこれまでどおり読めず、読めるようになるのは「要約」のほうです。

忙しい人のための要約

  • Responses API で reasoning={"summary": "auto"} を付けると、推論の要約が返る
  • 要約はレスポンスの reasoning 項目の summary 配列 に入る
  • 指定できる値は auto / concise / detailed の 3 つ
  • bedrock-runtime では Converse API でも使える(additionalModelRequestFields で指定)
  • 対象は Bedrock 上の OpenAI モデルすべて(リージョン内推論は bedrock-mantle、GEO・グローバルのクロスリージョン推論は bedrock-runtime から使う)

何がうれしいのか

「なぜその答えになったか」を回答と一緒に残せます。

  • デバッグ: プロンプトの意図と違う回答が返ったとき、どこで解釈がずれたかを追える
  • 評価: 答えが合っているかだけでなく、考え方が妥当かも見られる
  • 説明: エンドユーザーに「こう考えて回答しました」と添えられる

OpenAI のドキュメント(Reasoning summaries)

やってみた

手順 1: OpenAI SDK を入れる

OpenAI SDK に渡す API キーは、手元の AWS 認証情報から短期の Bedrock API キーを作って使います。

python3 -m venv .venv
source .venv/bin/activate
pip install openai aws-bedrock-token-generator boto3

手順 2: 要約なし / ありで比べる

cat > summary.py <<'EOF'
from openai import OpenAI
from aws_bedrock_token_generator import provide_token

client = OpenAI(
    api_key=provide_token(region="us-east-1"),
    base_url="https://bedrock-runtime.us-east-1.amazonaws.com/openai/v1",
)

for reasoning in [{"effort": "low"}, {"effort": "low", "summary": "auto"}]:
    r = client.responses.create(
        model="global.openai.gpt-5.6-luna",
        input="3人で12個のりんごを分けて、1人が2個食べたら残りはいくつ?",
        reasoning=reasoning,
        store=False,
    )
    print("===", reasoning)
    for item in r.output:
        if item.type == "reasoning":
            print("summary:", [s.text for s in item.summary])
    print("answer:", r.output_text)
EOF

python summary.py

summary を付けなかったほうは summary: [] と空で、付けたほうに要約が入ります。

スクリーンショット 2026-10-27 1.11.19.png

手順 3: Converse API でも取ってみる

bedrock-runtime では Converse API でも使えます(GPT-5.6 Sol のモデルカード)。専用のパラメータはないので、additionalModelRequestFields で Responses API と同じ reasoning を渡します。

boto3 は AWS の認証情報で直接署名するので、API キーは要りません。

cat > converse.py <<'EOF'
import boto3

client = boto3.client("bedrock-runtime", region_name="us-east-1")

r = client.converse(
    modelId="global.openai.gpt-5.6-luna",
    messages=[{"role": "user", "content": [{"text": "3人で12個のりんごを分けて、1人が2個食べたら残りはいくつ?"}]}],
    additionalModelRequestFields={"reasoning": {"effort": "low", "summary": "auto"}},
)

for block in r["output"]["message"]["content"]:
    if "reasoningContent" in block:
        print("summary:", block["reasoningContent"]["reasoningText"]["text"])
    if "text" in block:
        print("answer:", block["text"])
EOF

python converse.py

スクリーンショット 2026-10-27 1.17.48.png

回答とは別のブロック(reasoningContent)に要約が入って返ってきます。 Claude など他のモデルで推論を受け取るときと同じ場所なので、Converse を使っているアプリなら取り出し方を変えずに済みそうです。

まとめ

reasoning に summary を 1 つ足すだけで、回答と一緒に「どう考えたか」が返ってくるようになりました。Converse API でも取れるので、既存のアプリにも足しやすいかと思います。

推論モデルの回答がおかしいときの調査に、まずは auto から試してみると良さそうです。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?