GitHub Copilot, the AI-powered coding assistant, is evolving to become more efficient and context-aware. As Copilot takes on more complex tasks—from planning and debugging to multi-file changes—optimizing its use of tokens and selecting the right model for the job has become increasingly important. In this post, we’ll dive into how Copilot is improving context handling and model routing to deliver better results for developers.
The Quest for Efficiency
Efficiency in Copilot isn’t just about using fewer tokens; it’s about being smarter about how those tokens are used. For example, when working on long sessions in Visual Studio Code, Copilot often repeats information like instructions, repository context, and conversation history. To reduce this redundancy, Copilot is now caching recurring information and loading tool definitions only when needed.
Two key improvements are driving this efficiency:
- Prompt Caching: Copilot can now reuse model state for repeated prompt prefixes, avoiding the need to recompute the same information on every request.
- Tool Search: Instead of loading every tool definition into context on every turn, Copilot fetches tool definitions on demand. This is especially useful as Copilot integrates more tools, like terminal commands, file operations, and workspace search.
These changes ensure that Copilot can handle longer, more complex tasks without unnecessary overhead. For a deeper dive into the technical details, check out the VS Code technical deep dive.
Introducing Auto Model Selection
One of the biggest challenges in using AI tools is choosing the right model for the task at hand. GitHub Copilot’s Auto feature addresses this by automatically selecting the best model based on the task’s intent and current model health.
Here’s how it works:
- Real-Time Model Health: Auto tracks factors like model availability, speed, error rates, and cost to ensure that the selected model is both capable and ready to respond.
- Task-Aware Routing with HyDRA: This routing model considers the complexity of the task, reasoning depth, and other factors to choose the most suitable model. For instance, a quick explanation might use a more efficient model, while a complex debugging task might require a model with deeper reasoning capabilities.
By combining these signals, Auto avoids a one-size-fits-all approach, ensuring that developers get the best model for their specific task without manual intervention.
Making Auto Work in Real-World Scenarios
To make Auto practical for developers, GitHub has addressed several challenges:
- Cache-Aware Routing: Auto avoids switching models mid-conversation to preserve the prompt cache, which improves efficiency.
- Multilingual Support: Auto has been trained on conversations across 16 language families, ensuring it works well for developers around the world.
- Escalation Learning: Auto learns when a stronger model is needed and when a more efficient model can produce equally good results.
Expanding Auto Across Copilot
Auto with task intent is already live in Visual Studio Code, GitHub.com, and mobile. GitHub is now expanding this feature to Copilot CLI, GitHub App, and additional IDEs. Organizations will also have the option to set Auto as the default or enforce it as the only model selection option.
Tips for Maximizing Your AI Credits
While Copilot is becoming more efficient by default, there are a few habits developers can adopt to get even more value from their AI credits:
- Start with Auto: Let Copilot choose the best model for your task.
- Keep Context Focused: Start new sessions for different tasks and compact long-running sessions when needed.
- Avoid Mid-Session Changes: Switching models or settings mid-session can break cache reuse.
- Plan Before Parallelizing: For larger tasks, ask Copilot to plan first to ensure parallel agents are used effectively.
- Use Only Relevant Tools: Enable only the tools you need to avoid adding unnecessary context.
Final Thoughts
GitHub Copilot’s improvements in context handling and model routing are making it a more powerful and efficient tool for developers. By reducing redundancy, intelligently selecting models, and optimizing workflows, Copilot is helping developers focus on what matters most: building great software.
To learn more about these features and share your feedback, check out the Auto model selection docs and join the discussion on Copilot.
Happy coding! 🚀
