Home›GitHub Copilot›VS Code GitHub Copilot Chatの裏側:ステートレスLLMを操るコンテキスト&エージェント・オーケストレーションの全貌
VS Code GitHub Copilot Chatの裏側:ステートレスLLMを操るコンテキスト&エージェント・オーケストレーションの全貌

VS Code GitHub Copilot Chatの裏側:ステートレスLLMを操るコンテキスト&エージェント・オーケストレーションの全貌Inside VS Code GitHub Copilot Chat: Context and Agent Orchestration for Stateless LLMs

元記事を読むRead original articleqiita.com(新しいタブで開きます)(opens in a new tab)
AI2 点サマリ2 key points
  • VS Code GitHub Copilot Chatは、履歴、ツール、指示ファイルをクライアント側で再構成し、ステートレスなLLMに会話の連続性を持たせます。
  • Agent modeとPrompt Cachingの設計上の得失を示し、拡張可能なAIエージェント開発に役立ちます。
  • VS Code GitHub Copilot Chat rebuilds history, tools, and instruction files client-side for each stateless LLM call.
  • Agent mode and prompt caching trade-offs guide scalable agent design.

本ページの本文と要約は AI による自動生成です。日本語版と英語版は言語ごとに独立して生成されるため、表現や詳しさが異なる場合があります。正確性は元記事 (qiita.com) をご確認ください。The body and summaries are AI-generated independently for each language, so wording and detail may differ. Verify accuracy at the original source (qiita.com).

要約と収集メタデータに基づく AI 解説。元記事全文の転載・翻訳ではありません。AI explainer based on the summaries and collected metadata, not a copy or translation of the full source article.

ステートレスLLM

VS Code GitHub Copilot Chatの自然な会話やAgent modeの動作は、モデル自身の記憶ではなく、クライアント側のオーケストレーションによって実現される。重要なのは、状態をどこに置き、リクエストごとに何を再構成するかという設計だ。

LLM APIは基本的にステートレスであり、システム指示、ツール定義、会話履歴、今回の入力を送り直さなければ、直前のやり取りも把握できない。このため「さっきのファイルの続き」や「この変更を取り消して」といった要求に応じるには、必要な文脈を毎回そろえる必要がある。

クライアント側

履歴、ツール、指示ファイルは、LLMへの呼び出しごとにクライアント側で再構成される。状態をクライアントに寄せることで、プロキシとLLMは水平スケールしやすくなり、モデルの差し替えも容易になると説明されている。

一方、毎ターン全文脈を送信するため、帯域とトークンのコストが発生する。会話の連続性と運用上の扱いやすさを得る代わりに、送信量が増えるという非対称性がある。

指示の階層化

.github/copilot-instructions.mdはワークスペースルートで自動検出され、そのワークスペースの全チャットリクエストに適用される。*.instructions.mdは対象ファイルパターンに応じて条件付きで適用され、AGENTS.mdも常時有効な指示として扱える。

規約は一度伝えるだけでは次のリクエストに残らないため、毎ターンの注入がステートレス性への確実な対策となる。プロジェクト共通の指示は短くし、領域別の指示はapplyToで条件付きにする階層化が示されている。

Agent mode

Agent modeが数十ステップのタスクを自走できるのも、各ステップで必要な状態を組み立て直す仕組みに支えられている。増加する帯域とトークンのコストを緩和する役割を担うのがPrompt Cachingであり、連続性を保つ設計と送信コストの両立が要点となる。

Stateless LLMs

VS Code GitHub Copilot Chat creates conversational continuity even though LLM APIs are fundamentally stateless. This matters because the apparent memory behind requests such as continuing work on a previous file or undoing a change comes from client-side orchestration, not from the model remembering earlier interactions.

For every request, the system must resend the system instructions, tool definitions, conversation history, and current input. Without that reconstructed context, the model does not know even the immediately preceding exchange.

Context and Agent Orchestration

The client rebuilds the relevant history, tools, and instruction files for each LLM call. This orchestration also supports Agent mode, in which tasks can proceed through dozens of steps.

The central design choice is an asymmetry in where state is stored. Keeping state on the client makes the proxy and LLM easier to scale horizontally and makes replacing the model easier. The trade-off is that the full context must be transmitted on every turn, creating bandwidth and token costs.

Instruction Files

According to the official documentation cited by the article, .github/copilot-instructions.md is automatically detected at the workspace root and applied to every chat request in that workspace. Files matching *.instructions.md can be applied conditionally according to target file patterns, while AGENTS.md can also be treated as a continuously active set of instructions.

Because the LLM does not retain instructions between requests, a convention supplied once will not be present in the next request unless it is injected again. Repeating instructions every turn is presented as the simplest and most reliable response to statelessness.

The proposed organizational approach is hierarchical: keep project-wide instructions short, and use applyTo to conditionally apply instructions for specific areas.

Prompt Caching

Sending complete context on each turn has an explicit cost in bandwidth and tokens. Prompt Caching is the mechanism identified for mitigating that cost.

Together, client-side state reconstruction, conditional instruction handling, Agent mode, and prompt caching define the design trade-offs behind the chat experience and provide guidance for scalable, extensible AI agent development.

ポコとTECHガイドPoko & TECH Guide

ポコと当サイトのTECHガイドが、記事の要約と収集した情報から読みどころを語るAI生成の対話です。Poko and TECH Dashboard's own TECH Guide discuss the article's highlights in an AI-generated conversation based on its summary and collected source details.

  1. ポコPokoエディタで相談すると、普段の作業は何が変わるの? さっきの話を毎回説明し直さなくていいのかな。What changes in everyday editor work? Do I no longer need to explain the previous conversation every time?
  2. TECHガイドTECH Guide「さっきのファイルの続き」や変更の取り消しを頼めます。Agent modeでは、数十ステップのタスクも自走します。You can ask it to continue with a previous file or undo a change. In Agent mode, it can also work through tasks spanning dozens of steps.
  3. ポコPoko前はできなかったの? LLMが会話をずっと覚えているわけじゃないのかな。Couldn’t it do that before? I guess the LLM doesn’t actually remember the whole conversation?
  4. TECHガイドTECH GuideLLM APIは基本的にステートレスで、送り直さなければ直前の会話も知りません。連続性はモデルの記憶ではなく、クライアント側の再構成です。LLM APIs are generally stateless, so they don’t know the prior exchange unless it’s sent again. The continuity comes from client-side reconstruction, not model memory.
  5. ポコPokoなるほど、会話が続く鍵は「覚えるAI」より、履歴や指示を毎回そろえる仕組みなんだね。Got it—the key isn’t an AI that remembers, but a system that assembles the history and instructions for every request.
  6. TECHガイドTECH Guideそう捉えられます。次は、毎ターン送る帯域・トークンコストをPrompt Cachingや指示の階層化でどう抑えるかに注目です。That’s the idea. Next, watch how prompt caching and layered instructions address the bandwidth and token costs of resending context each turn.
記事情報・収集記録Article details & collection record
出典Source
Qiita VSCodeコミュニティCommunity
公開日時 (JST)Published (JST)
収集日時 (JST)Collected (JST)
配信形式Format
ブログBlog
原文言語Source language
JA
重要度の位置づけImportance in this lane
MediumMedium priority(GitHub Copilot 218件中、同等以上 166件)(166 of 218 GitHub Copilot entries are equal or higher)
出典の平均重要度(掲載直近 30 件・最大 30 件)Source average (last 30 listed, up to 30)
1.7 / 31=情報 · 2=中 · 3=高1=Info · 2=Medium · 3=High
情報の寿命Half-life
中期 (チュートリアル)Medium-term (tutorial)

🧠GitHub Copilot の他の記事More from GitHub Copilotもっと見る →View more →

ページ上部へScroll to top