Skip to content

Commit dedb3d8

Browse files
committed
Add usage optimization guide and cross-references
1 parent 022906f commit dedb3d8

10 files changed

Lines changed: 134 additions & 6 deletions

File tree

build/sitemap.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,11 @@
610610
<changefreq>weekly</changefreq>
611611
<priority>0.8</priority>
612612
</url>
613+
<url>
614+
<loc>https://code.visualstudio.com/docs/copilot/guides/optimize-usage</loc>
615+
<changefreq>weekly</changefreq>
616+
<priority>0.8</priority>
617+
</url>
613618
<url>
614619
<loc>https://code.visualstudio.com/docs/copilot/guides/customize-copilot-guide</loc>
615620
<changefreq>weekly</changefreq>

docs/copilot/best-practices.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,13 @@ Each AI model has different strengths. Some are better at reasoning, others exce
133133
134134
* **Use BYOK for additional control.** Bring your own API key for more model choices and hosting options.
135135
136+
* **Consider credit consumption.** More capable models consume more [AI credits](/docs/copilot/concepts/language-models.md#ai-credits-and-model-costs) per token. Auto model selection balances quality and cost automatically. For more tips, see [optimize AI credit usage](/docs/copilot/guides/optimize-usage.md).
137+
136138
For more information, see [selecting AI models](/docs/copilot/customization/language-models.md) and [available models for Copilot Chat](https://docs.github.com/en/copilot/using-github-copilot/ai-models/changing-the-ai-model-for-copilot-chat).
137139
138140
## Plan first, then implement
139141
140-
For complex changes that span multiple files, separate planning from implementation. This approach prevents the AI from solving the wrong problem.
142+
For complex changes that span multiple files, separate planning from implementation. This approach prevents the AI from solving the wrong problem and avoids spending [AI credits](/docs/copilot/concepts/language-models.md#ai-credits-and-model-costs) on code that needs to be thrown away.
141143
142144
1. **Explore.** Use ask mode or a subagent to read the relevant code and understand how it works before making changes.
143145
1. **Plan.** Use the [Plan agent](/docs/copilot/agents/planning.md) to create a structured implementation plan. Review and refine the plan before executing.
@@ -164,19 +166,21 @@ For more information, see [GitHub Copilot security](/docs/copilot/security.md) a
164166
165167
AI responses might degrade as the conversation fills with irrelevant context. Manage your sessions proactively.
166168
167-
* **Start new sessions for unrelated tasks.** Don't keep piling unrelated questions into one conversation. Context pollution reduces response quality.
169+
* **Start new sessions for unrelated tasks.** Don't keep piling unrelated questions into one conversation. Context pollution reduces response quality and wastes tokens on irrelevant history.
168170
169171
* **Remove irrelevant history.** Delete past questions and responses that are no longer relevant, or start a fresh session.
170172
171-
* **Compact context.** Use [/compact](/docs/copilot/chat/copilot-chat-context.md#context-compaction) and provide instructions to selectively compact the context and retain only the most relevant information.
173+
* **Compact context.** Use [/compact](/docs/copilot/chat/copilot-chat-context.md#context-compaction) and provide instructions to selectively compact the context and retain only the most relevant information. Compacting reduces the tokens sent with each subsequent request, which helps [manage AI credit usage](/docs/copilot/guides/optimize-usage.md).
172174
173175
* **Use subagents for investigation.** Hint the AI to perform research and exploration in isolation by using [subagents](/docs/copilot/agents/subagents.md) so the findings don't clutter your main context.
174176
175177
* **Choose the right session type.** Use local sessions for quick tasks on your current code that need your immediate attention, background tasks for tasks that can run locally and isolated from your main context, or cloud sessions that can benefit from team-collaboration.
176178
177179
* **Scale with parallel sessions.** Run multiple sessions in parallel for independent tasks to save time and keep contexts separate. You can have multiple sessions running at once, across local, background, and cloud environments, and switch between them via the [sessions list](/docs/copilot/chat/chat-sessions.md#sessions-list) in VS Code.
178180
179-
For more information, see [session management](/docs/copilot/chat/chat-sessions.md) and [workspace indexing](/docs/copilot/reference/workspace-context.md).
181+
* **Fork instead of re-prompting.** Use [`/fork`](/docs/copilot/chat/chat-sessions.md#fork-a-chat-session) to explore alternatives without losing context, instead of starting over and re-establishing context from scratch.
182+
183+
For more information, see [session management](/docs/copilot/chat/chat-sessions.md), [workspace indexing](/docs/copilot/reference/workspace-context.md), and [optimize AI credit usage](/docs/copilot/guides/optimize-usage.md).
180184
181185
## Work with large codebases
182186

docs/copilot/chat/copilot-chat-context.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ As you send more requests in a conversation, the control updates to reflect the
127127
128128
## Context compaction
129129

130-
As a conversation grows, the accumulated messages and context can fill up the model's context window. Context compaction summarizes the conversation history to free up space, so you can continue working in the same session without losing important details.
130+
As a conversation grows, the accumulated messages and context can fill up the model's context window. Context compaction summarizes the conversation history to free up space, so you can continue working in the same session without losing important details. Compacting also reduces the number of tokens sent with each subsequent request, which helps manage [AI credit consumption](/docs/copilot/guides/optimize-usage.md).
131131

132132
### Automatic compaction
133133

docs/copilot/concepts/language-models.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ For more details, see [About Copilot auto model selection](https://docs.github.c
8080

8181
Each Copilot plan includes a monthly allowance of [AI credits](https://docs.github.com/en/copilot/concepts/billing/usage-based-billing-for-individuals). Different models consume AI credits at different rates, based on the model and the number of tokens processed. More capable models cost more per token, while lighter models extend your usage further. When you use auto model selection, VS Code routes each request to an efficient model that balances quality and cost.
8282

83+
Other factors also affect credit consumption, such as [thinking effort](/docs/copilot/customization/language-models.md#configure-thinking-effort) (higher effort produces more thinking tokens), context window size, and tool usage. For practical tips on reducing credit consumption, see [optimize AI credit usage](/docs/copilot/guides/optimize-usage.md).
84+
8385
Learn how to [choose and configure language models](/docs/copilot/customization/language-models.md) in VS Code.
8486

8587
## Bring your own language model key

docs/copilot/concepts/tools.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Use the **Configure Tools** button in the chat input field to enable or disable
4343
Limiting the available tools can help in several ways:
4444

4545
* **Preserve context**: every tool call produces output that consumes space in the [context window](/docs/copilot/concepts/language-models.md#context-window). Fewer tools means the agent is less likely to make unnecessary calls that fill up the context.
46+
* **Reduce credit consumption**: unnecessary tool calls increase token usage and consume more [AI credits](/docs/copilot/concepts/language-models.md#ai-credits-and-model-costs). Disabling tools you don't need for a task helps keep costs down.
4647
* **Get more relevant results**: when fewer tools are available, the agent focuses on the most appropriate ones rather than choosing from a large set.
4748
* **Improve performance**: a smaller tool set reduces the decision space for the model, which can speed up responses.
4849

docs/copilot/customization/language-models.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ Some models support configurable thinking effort, which controls how much reason
4242

4343
By default, VS Code sets recommended effort levels and has adaptive reasoning enabled, where the model dynamically determines how much to think based on the complexity of each request. For most use cases, the defaults work well.
4444

45+
> [!TIP]
46+
> Higher thinking effort produces more thinking tokens, which increases [AI credit](/docs/copilot/concepts/language-models.md#ai-credits-and-model-costs) consumption. Only increase thinking effort for genuinely complex tasks. Learn more about [optimizing AI credit usage](/docs/copilot/guides/optimize-usage.md).
47+
4548
To configure the thinking effort:
4649

4750
1. Open the model picker in the chat input field and select a reasoning model.

docs/copilot/faq.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ You can view the current Copilot usage in the Copilot status dashboard, availabl
4040
* **Inline suggestions**: The percentage of inline suggestions quota you have used in the current month. Paid plans have an unlimited quota for inline suggestions.
4141
* **AI credits**: The percentage of your monthly AI credits allowance you have used in the current month.
4242

43-
Visit the GitHub Copilot documentation for more information about [monitoring usage and entitlements](https://docs.github.com/en/copilot/managing-copilot/monitoring-usage-and-entitlements/monitoring-your-copilot-usage-and-entitlements).
43+
Visit the GitHub Copilot documentation for more information about [monitoring usage and entitlements](https://docs.github.com/en/copilot/managing-copilot/monitoring-usage-and-entitlements/monitoring-your-copilot-usage-and-entitlements). For tips on reducing credit consumption, see [optimize AI credit usage](/docs/copilot/guides/optimize-usage.md).
4444

4545
### I reached my inline suggestions or AI credits limit
4646

@@ -52,6 +52,8 @@ For users on Copilot Free, to access more inline suggestions and AI credits, you
5252

5353
If you're on a paid plan and exhaust your AI credits, you can set a budget for additional usage and keep working, or wait until the next monthly cycle when your allowance resets. Learn more about [what happens if you exceed your included AI credits](https://docs.github.com/en/copilot/concepts/billing/usage-based-billing-for-individuals#what-happens-if-i-exceed-my-included-ai-credits) in the GitHub Copilot documentation.
5454

55+
For tips on reducing credit consumption, see [optimize AI credit usage](/docs/copilot/guides/optimize-usage.md).
56+
5557
### My Copilot subscription is not detected in VS Code
5658

5759
To use chat in Visual Studio Code, you must be signed into Visual Studio Code with a GitHub account that has access to GitHub Copilot.

docs/copilot/guides/context-engineering-guide.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,8 @@ Following these best practices helps you establish a sustainable and effective c
247247

248248
**Maintain context isolation**: Keep different types of work (planning, coding, testing, debugging) in separate chat sessions to prevent context mixing and confusion.
249249

250+
**Be mindful of credit consumption**: More context files, larger instruction sets, and complex agent chains all increase token usage and [AI credit](/docs/copilot/concepts/language-models.md#ai-credits-and-model-costs) consumption. Start with concise context and expand only when needed. For more tips, see [optimize AI credit usage](/docs/copilot/guides/optimize-usage.md).
251+
250252
### Documentation strategies
251253

252254
**Create living documents**: Treat your custom instructions, custom agents, and templates as evolving resources. Refine them based on observed AI mistakes or shortcomings.
@@ -269,6 +271,8 @@ Following these best practices helps you establish a sustainable and effective c
269271

270272
**Version your context**: Use git to track changes to your context engineering setup, allowing you to revert problematic changes and understand what works best.
271273

274+
**Verify cache performance**: Use the [Agent Debug Logs](/docs/copilot/chat/chat-debug-view.md) to check prompt cache hit rates and token usage. Good cache performance means your context setup is structured in a way that the model provider can reuse previous request prefixes, reducing latency and token costs.
275+
272276
### Anti-patterns to avoid
273277

274278
**Context dumping**: Avoid providing excessive, unfocused information that doesn't directly help with decision-making.
@@ -279,6 +283,8 @@ Following these best practices helps you establish a sustainable and effective c
279283

280284
**One-size-fits-all**: Different team members or project phases may need different context configurations. Be flexible in your approach.
281285

286+
**Over-engineering agent chains**: Deeply nested subagent workflows and excessive tool calls multiply token usage and [credit consumption](/docs/copilot/concepts/language-models.md#ai-credits-and-model-costs). Keep agent chains as shallow as practical and limit tools to what each agent actually needs.
287+
282288
### Measuring success
283289

284290
A successful context engineering setup should result in:

0 commit comments

Comments
 (0)