Domain 5 of 6 · Chapter 2 of 2

Engineer Prompts for Performance

Unlock the complete study guide.

Bundled into the existing GitHub Copilot premium course — no separate purchase.

14-day money-back guarantee — no questions asked.

Included in this chapter:

  • The assembled request: what the model actually receives
  • The chat prompt process flow
  • Context that changes while the prompt stays the same
  • Context sources by Copilot surface
  • Selecting context: indexing, discovery and #-mentions
  • One context window for every source
  • Chat history: session context, not training
  • Managing history: four useful moves
  • Iterating on a response that missed
  • Practice pitfalls: prompt performance

Four useful moves for managing chat history

AspectFollow-up promptDelete a turnCompactionNew session
Use whenThe next request builds on earlier turnsA turn is stale or led to a failed resultThe same task continues but history has grown largeYou switch to an unrelated task
What happens to earlier historyEarlier turns can resolve references, unless compacted or omittedThat request and response are removed from the chat history (which is sent with later requests)Older turns are replaced by a summaryHistory is not automatically shared with a new chat
Main riskStale or unrelated turns keep competing for contextRemoving a turn that later prompts still refer toEarlier details may be summarized or omittedDecisions you still need must be supplied again

Decision tree

Is the next request onthis session's task?NoNew sessionold history stays behindYesDid a turn go stale orset a failed direction?YesDelete a turnremoved from chat historyNoHas history grown largefor this same task?YesCompactionsummary replaces older turnsNoFollow-up promptearlier turns resolve references

Cheat sheet

  • Refine a response by adding focused constraints
  • Choose between modifying a useful suggestion and restarting a poor one
  • Rephrase or narrow an unhelpful request
  • Course-correct as soon as the response takes a wrong direction
  • A model request combines multiple context layers
  • The model can reason only over information in the current context
  • Tool results can expand context during an agent loop
  • Implicit context reflects the developer's current editor state
  • Workspace indexing selects relevant code by meaning
  • Automatic context discovery does not guarantee a particular source
  • VS Code #-mentions add a chosen type of context
  • Available context sources vary by Copilot surface
  • GitHub.com contextual chat accumulates page references during navigation
  • Every context source shares a bounded context window
  • Prefer focused context over maximum context volume
  • Compaction trades detail for additional context capacity
  • A growing context can reduce response quality
  • Chat history supplies context for follow-up references
  • A focused history supports progressive refinement
  • Conversation history is scoped to its session
  • Session history provides context rather than retraining the model
  • Chat history supplies context for follow-up prompts within the conversation
  • Start a new session for an unrelated task
  • Remove history that is stale or led to a failed result
  • Summarize essential context before continuing a long thread
  • Compact a long but still-focused conversation
  • Copilot preprocesses the prompt and combines it with context
  • The language model generates from the assembled input and context
  • Copilot formats the generated response for presentation
  • The Copilot surface controls which context can enter the flow

Unlock with Premium — includes all practice exams and the complete study guide.

Also tested in

References

  1. https://docs.github.com/en/copilot/how-tos/manage-your-account/manage-policies
  2. https://code.visualstudio.com/docs/agents/concepts/context
  3. https://learn.microsoft.com/en-us/credentials/certifications/resources/study-guides/gh-300
  4. https://code.visualstudio.com/docs/agents/concepts/agents
  5. https://docs.github.com/en/copilot/concepts/prompting/prompt-engineering
  6. https://docs.github.com/en/copilot/responsible-use/chat
  7. https://code.visualstudio.com/docs/agent-customization/custom-agents
  8. https://code.visualstudio.com/docs/agents/concepts/language-models
  9. https://github.blog/changelog/2026-05-18-ask-questions-in-context-with-copilot-on-web/
  10. https://code.visualstudio.com/docs/chat/copilot-chat-context
  11. https://docs.github.com/en/copilot/tutorials/optimize-ai-usage
  12. https://docs.github.com/en/copilot/tutorials/optimize-chat-usage
  13. https://code.visualstudio.com/docs/agents/concepts/sessions
  14. https://docs.github.com/en/copilot/how-tos/configure-custom-instructions/add-repository-instructions
  15. https://code.visualstudio.com/docs/agents/guides/get-agent-back-on-track
  16. https://docs.github.com/en/copilot/reference/copilot-cli-reference/cli-command-reference
  17. https://docs.github.com/en/copilot/concepts/agents/copilot-cli/context-management
  18. https://code.visualstudio.com/docs/copilot/prompt-crafting
  19. https://docs.github.com/en/copilot/get-started/best-practices