Persist agent state and manage context drift
Unlock the complete study guide.
Bundled into the existing Developing in Agentic AI Systems premium course — no separate purchase.
14-day money-back guarantee — no questions asked.
Included in this chapter:
- Why task state has to live outside the conversation
- What compaction keeps, what it loses and how to steer it
- Diagnosing drift and correcting course
- The Copilot CLI session-state directory
- Resuming and forking a Copilot CLI session
- Rolling back conversation, files and history
- The upgrade scenario folder: which file answers which question
- Acting on an existing scenario folder
- Exam reasoning: evidence over recollection
Which record or command answers which question, and the tempting answer that does not
| What you need to know | What answers it | Tempting answer that does not |
|---|---|---|
| Which upgrade steps and validations actually finished | `tasks.md`, updated with every step's status | The upgrade `plan.md`, which records the intended approach, not completion |
| What strategy was confirmed during the upgrade assessment | `upgrade-options.md` | `assessment.md`, which records findings and scope |
| Which breaking changes and API problems the analysis found | `assessment.md` | `tasks.md`, which tracks execution status |
| How one resumed upgrade task went, in detail | `tasks/{taskId}/progress-details.md` | The step status in `tasks.md` alone |
| What one upgrade task was meant to cover | `tasks/{taskId}/task.md` | The scenario-wide `plan.md` |
| Upgrade preferences that must outlast the chat | `scenario-instructions.md` | A chat message that ends with the exchange |
| The complete recorded Copilot CLI session | `events.jsonl` in the session-state directory | A Copilot CLI compaction checkpoint summary |
| Metadata about a Copilot CLI session | `workspace.yaml` | `events.jsonl` or `plan.md` |
| What a Copilot CLI compaction kept | `/session checkpoints NUMBER` | Assuming the active summary is lossless |
| The current CLI implementation plan | `/session plan`, or `plan.md` in the session-state directory | Reconstructing the steps from memory |
| Working files that must stay out of the repository | Session artifacts listed by `/session files` | Committing scratch files to the repository |
| Which session `copilot --continue` opens | The latest in the current directory, else the global latest | Always the session for the task you had in mind |
Decision tree
Cheat sheet
Unlock with Premium — includes all practice exams and the complete study guide.