講座 › 分野6 プロンプトとコンテキストのエンジニアリング
6.3 出力の処理
配点 2.6%Output Handling
出力は「使う前に確かめる」。形式はスキーマで保証し、中身は根拠と照らし、自信ありげな答えをそのまま信じない。
未読
構造化出力のパターン 読了

構造化出力が無いと、Claudeが壊れたJSONや無効なツールの入力を返し、アプリが止まることがあります。構造化出力(output_config.format)や、ツールの strict: true を使うと、スキーマどおりの形が保証されます。
出典:Structured outputs
Without structured outputs, Claude can generate malformed JSON responses or invalid tool inputs that break your applications.https://platform.claude.com/docs/en/build-with-claude/structured-outpu…(取得 2026-11-17)
出典:Structured outputs
Guarantee schema validation on tool names and inputs.https://platform.claude.com/docs/en/build-with-claude/structured-outpu…(取得 2026-11-17)
応答の検証と防御的なパース 読了

形が正しくても、処理の前に応答を確かめます。まず stop_reason を見て、max_tokens で途中で切れていないか、refusal で断られていないかを確認します。切れた応答をそのまま解析しないことが、防御的なパースの基本です。
出典:Handling stop reasons
Learn what each stop_reason value means and how to handle truncation, tool use, paused turns, and refusals in your application.https://platform.claude.com/docs/en/build-with-claude/handling-stop-re…(取得 2026-11-17)
出典:Handling stop reasons
The response filled the model’s context window. | Treat the response as truncated.https://platform.claude.com/docs/en/build-with-claude/handling-stop-re…(取得 2026-11-17)
自信に満ちた出力を鵜呑みにしない 読了

幻覚(もっともらしい誤り)を減らすには、分からないときは分からないと言ってよいと明示します。長い文書では、まず原文をそのまま引用させてから作業させます。主張ごとに引用と出典を付けさせると、後から確かめられます。裏付けの引用が見つからない主張は取り下げさせます。
出典:Reduce hallucinations
Explicitly give Claude permission to admit uncertainty. This technique can drastically reduce false information.https://platform.claude.com/docs/en/test-and-evaluate/strengthen-guard…(取得 2026-11-17)
出典:Reduce hallucinations
ask Claude to extract word-for-word quotes first before performing its taskhttps://platform.claude.com/docs/en/test-and-evaluate/strengthen-guard…(取得 2026-11-17)
出典:Reduce hallucinations
Make Claude’s response auditable by having it cite quotes and sources for each of its claims.https://platform.claude.com/docs/en/test-and-evaluate/strengthen-guard…(取得 2026-11-17)
試験のポイント
- 形式の保証はスキーマ、中身の保証は根拠の引用。どちらも「使う前に確かめる」。
出典:Structured outputs
Structured outputs guarantee schema-compliant responses through constrained decoding
https://platform.claude.com/docs/en/build-with-claude/structured-outpu…(取得 2026-11-17) - 分からないと言ってよい、と伝えるだけで誤りは大きく減る。
出典:Reduce hallucinations
Allow Claude to say “I don’t know”
https://platform.claude.com/docs/en/test-and-evaluate/strengthen-guard…(取得 2026-11-17)