講座 › 分野6 プロンプトとコンテキストのエンジニアリング
6.1 コンテキストエンジニアリング
配点 3.8%Context Engineering
コンテキストは有限の資源。望む結果を得るための、最小で中身の濃いトークンの組み合わせを探す。溜まったら刈り込み・圧縮・分離。
未読
コンテキストは有限の資源 読了

LLMは、人と同じように、情報が多すぎると集中を失います。コンテキストは、増やすほど効果が薄れる有限の資源として扱います。良いコンテキストエンジニアリングとは、望む結果が出る可能性を最大にする、最小で中身の濃いトークンの組み合わせを見つけることです。ウィンドウが大きくなっても、関係のない情報で汚れる問題は残ります。
出典:Effective context engineering for AI agents
Context, therefore, must be treated as a finite resource with diminishing marginal returns.https://www.anthropic.com/research/effective-context-engineering-for-a…(取得 2026-11-17)
出典:Effective context engineering for AI agents
good context engineering means finding the smallest possible set of high-signal tokens that maximize the likelihood of some desired outcomehttps://www.anthropic.com/research/effective-context-engineering-for-a…(取得 2026-11-17)
肥大化を防ぐ:ツール出力の刈り込み 読了

ずっと前に呼んだツールの生の結果を、エージェントがもう一度見る必要はほとんどありません。古いツールの結果を消すのは、最も安全で軽い圧縮の方法の1つです。APIのコンテキスト編集を使うと、会話の履歴から特定の内容(ツールの結果や思考)を選んで消せます。
出典:Effective context engineering for AI agents
once a tool has been called deep in the message history, why would the agent need to see the raw result again?https://www.anthropic.com/research/effective-context-engineering-for-a…(取得 2026-11-17)
出典:Context editing
Context editing allows you to selectively clear specific content from conversation history as it grows.https://platform.claude.com/docs/en/build-with-claude/context-editing.…(取得 2026-11-17)
コンパクション(圧縮) 読了

コンパクションは、上限に近づいた会話を要約し、その要約で新しいコンテキストを始めることです。APIのサーバー側のコンパクションは、古いやり取りをClaudeが書いた要約に置き換えるので、自分で要約の処理を書く必要がありません。何を残すかが肝心で、削りすぎると後で重要と分かる細部を失います。
出典:Effective context engineering for AI agents
Compaction is the practice of taking a conversation nearing the context window limit, summarizing its contents, and reinitiating a new context window with the summary.https://www.anthropic.com/research/effective-context-engineering-for-a…(取得 2026-11-17)
出典:Compaction
Compaction replaces the older turns of a conversation with a summary that Claude writes on the server, so you need no summarization code of your own.https://platform.claude.com/docs/en/build-with-claude/compaction.md(取得 2026-11-17)
出典:Effective context engineering for AI agents
overly aggressive compaction can result in the loss of subtle but critical contexthttps://www.anthropic.com/research/effective-context-engineering-for-a…(取得 2026-11-17)
ドリフトを防ぐ:サブエージェントでの分離とツールの遅延読み込み 読了

1つのエージェントにプロジェクト全体の状態を持たせる代わりに、専門のサブエージェントにきれいなコンテキストで集中した作業をさせ、要点だけを返させます。ツールが多い場合は、ツール検索で必要な定義だけをその場で読み込みます。最初に全部の定義を入れると、作業前から多くのトークンを使い、ツールが30〜50を超えると選び間違いも増えます。
出典:Effective context engineering for AI agents
specialized sub-agents can handle focused tasks with clean context windowshttps://www.anthropic.com/research/effective-context-engineering-for-a…(取得 2026-11-17)
出典:Tool search tool
Claude’s ability to pick the right tool degrades once you exceed 30–50 available tools.https://platform.claude.com/docs/en/agents-and-tools/tool-use/tool-sea…(取得 2026-11-17)
試験のポイント
- ウィンドウを大きくするより、入れるものを絞る。古いツールの結果は消す。
出典:Effective context engineering for AI agents
One of the safest lightest touch forms of compaction
https://www.anthropic.com/research/effective-context-engineering-for-a…(取得 2026-11-17) - 長い会話はコンパクション、独立した調査はサブエージェントで分離。
出典:Context editing
is the primary strategy for managing context in long-running conversations
https://platform.claude.com/docs/en/build-with-claude/context-editing.…(取得 2026-11-17)