Text of docs.github.com › en › copilot › tutorials › optimize-ai-usage as Styx crawled it on Nov 19, 2026. The page may have changed since. Only its words are kept, without pictures or layout, and only the first part of a long page.

Open the live page

Optimizing your AI usage to maximize efficiency and reduce cost - GitHub Docs

Skip to main content Skip to content Collapse sidebar Expand sidebar Optimizing your AI usage to maximize efficiency and reduce cost Learn how to choose the right models, structure your prompts, and add guardrails so that Copilot completes tasks more efficiently and uses fewer AI credits. In this article Introduction The strategies outlined in this article show you how to improve Copilot efficiency and, as a result, use fewer AI credits.

1. Choose the right model for the right task By selecting the right capability level for your task, configuring reasoning appropriately, and leveraging auto model selection and cheaper models for specific workloads, you can maintain quality while significantly reducing token consumption. Select the right model Model choice is one of the fastest ways to improve cost efficiency, but it is often overlooked. A common pattern is to default to the most capable model for every task—but this often increases token usage without improving the outcome.

In some execution-heavy scenarios, overusing reasoning models can reduce quality because the model may overthink the task or introduce unnecessary changes. Choose the model based on the work involved: Reasoning models : Best for architecture decisions, complex debugging, system design, and tasks that require deeper analysis. Mid-tier models : Best when the plan is already clear and the agent needs to execute efficiently.

Lighter models : Best for refactoring, formatting, documentation updates, and other routine, well-scoped changes. Use as much capability as the task requires, and as little as necessary. Matching capability to task improves outcomes and directly controls costs at scale. For a breakdown by model and task type, see AI model comparison . Configure the reasoning level of the model Some models also support configurable reasoning levels, which control how much the model reasons before it responds.

A higher level can improve answers to complex problems, but it consumes more tokens, and therefore more credits, so you should use the regular level by default and raise it only for harder tasks. Configurable reasoning is available for Visual Studio Code and Copilot CLI for supported models. See Supported AI models in GitHub Copilot . Use Copilot Fusion as your default Copilot Fusion evaluates each task and uses capability signals for reasoning, code generation, debugging, and tool use, to select the most efficient execution pattern that meets the quality bar for your chosen effort level.

Execution patterns either choose a single best model for the task or use multiple models to do review passes for the best result for your task. Selecting an effort level lets you prioritize the quality, cost, and capability tradeoffs that the system prioritizes for each prompt. There are three effort levels you can choose from: Fusion Standard : Balances cost, quality, and latency. Fusion High : Balanced orchestration with moderate token savings.

Fusion Max : Frontier capability while still considering token efficiency. Copilot Fusion keeps your main conversation on the same model whenever possible, so the conversation continues to benefit from cached tokens. Models that assist, such as a reviewer, receive only the context they need. To understand more about why this matters, see 4. Preserve the cache . Note Through November 30, 2026, users on paid Copilot plans receive a 30% discount on model costs when using Copilot Fusion.

For more information, see About GitHub Copilot Fusion . Use cheaper models for subagents Run subagents on cheaper models. Subagents run in their own session and don't inherit the main agent's conversation history. Because their context is scoped to a single focused task, a lighter model is often sufficient—and assigning one doesn't affect the main agent's cache the way a mid-session model switch would. 2. Provide clear guidance in your prompts Your prompt sets the direction for everything the agent does.

When a prompt is vague, the agent has to infer intent, explore more context, and make judgment calls. That often leads to retries, scope drift, and unnecessary token usage. Well-structured prompts have three qualities: A clear task definition. Instead of "fix this issue," explain what the issue is, where it occurs, and what the expected outcome looks like. Relevant context provided upfront. If you already know which files, services, logs, errors, or inputs matter, include them.

This helps the agent avoid unnecessary exploration. A clear stopping condition. Tell the agent what "done" looks like. Without a stopping point, agents can continue beyond the goal by adding extra commits, refactoring unrelated code, or expanding scope. This added guidance doesn't meaningfully increase token usage, but it can significantly reduce the number of agent runs needed to reach the right outcome. For prompt engineering best practices, see Prompt engineering for GitHub Copilot .

3. Keep your context lean Copilot sends the context it has access to as input tokens, and that context adds up: open editor tabs, attached files, and the full back-and-forth of a long conversation all count as context. To keep context under control, consider doing the following: Start a new conversation when you switch problems A long thread carries its entire history into every new request. When you move on to an unrelated task, start a new conversation.

For example: In Copilot CLI use /new (or /clear ) In Copilot Chat, start a new chat session. Compact long Copilot CLI sessions that you want to continue When you need the thread to keep going but it has grown large, run /compact in Copilot CLI to summarize the history and shrink the context window, optionally focusing the summary (for example, /compact focus on the auth module ). In addition, you can use /context to check current usage at any time.

See Managing context for GitHub Copilot . Give Copilot a map of your project A well-maintained custom instructions file, such as an AGENTS.md or .github/copilot-instructions.md file, gives agents a structural overview of your repository so they don't have to read large numbers of files just to orient themselves. See Support for different types of custom instructions . Bring in only the tools you need Large tool sets (for example, a full MCP server's worth of tools) add to the context on every request.

Where it fits your workflow, enable only the toolsets relevant to the task. See Configuring toolsets for the GitHub MCP Server . 4. Preserve the cache Caching lets an AI model store portions of a conversation's context so they don't need to be reprocessed on every request. In agentic coding, where the same large context—system prompt, file contents, tool definitions—is sent repeatedly across many turns, caching has an impact: the cached portion from the previous response is reused rather than reprocessed, and cached tokens are typically billed at 10% of the normal input price.

See Models and pricing for GitHub Copilot . However, the following actions invalidate the cache, causing the full context to be re-sent and billed as fresh input tokens: Switching models mid-session . A different model can't reuse another model's cache, so the next request rebuilds it from scratch. Pick a model (or use Copilot auto model selection) and stick with it for the session. Coming back to an old session . Caches expire after a period of inactivity (24 hours for OpenAI models and 1 hour for most others).

If you've been away a while, start a new session, or run /compact (in Copilot CLI) so what gets rebuilt is a short summary rather than the full history. Changing reasoning mid-session . Changing the reasoning effort level, context size, or the set of enabled tools and MCP servers during a session invalidates the cache. Configure these settings before you start and leave them unchanged for the session. 5. Set AI credit session limits An AI credit session limit caps the amount of work Copilot performs on a single session.

In Copilot

The rest of this page is on the live site.