Domain 4 of 6 · Chapter 3 of 3

Maintain agent memory and state across tools and environments

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:

  • State, memory, and the boundaries that destroy them
  • Passing files between jobs and runs with workflow artifacts
  • How long saved state actually survives
  • Reading versus deleting an artifact: two different access levels
  • Copilot Memory: what is stored, what is re-checked, and who owns it
  • Carrying work across sessions, editors, and environments
  • Instructions and shared guidance as durable context
  • Batching pull request feedback for Copilot cloud agent
  • Reading an exam scenario: cues, boundaries, and the tempting wrong answer

What each continuity carrier actually moves, and what ends it

CarrierBoundary it crossesWhat it carriesWhat ends or blocks it
Workflow artifact (upload/download-artifact)Job to job in a run; run to later inspectionSelected files: plans, traces, progress recordsRetention expiry, manual deletion by a write-access user, or deleting the workflow run
Committed state folder (.github/upgrades/{scenarioId})Session to session and environment to environment, as a task-state recordUpgrade stage records and live task progressCopying only the code changes and leaving that state folder uncommitted
Exported session (VS Code Export Chat JSON, CLI /share file)Person to person and tool to toolPrompts and responses as a portable saved record; it applies no changes and is not a resumable sessionDepends on preserving the exported file
Session sync and session historyDevice to device for one signed-in userLocal Copilot session historychat.sessionSync.enabled set to false, an excludeRepositories match, or a policy that disables session sync
Native handoff to another Session TargetSession Target to Session Target, such as Copilot to Cloud with Copilot cloud agentConversation history and context, but not the previous target's tools, permissions, and modelsRequires another supported Session Target; opening the same session in the Agents window instead of the Chat view changes only where you view it, not the target
External-session discovery in VS CodeCopilot CLI to VS Code for supported local sessionsA local session, opened for continuationHidden until the External filter is applied; discovery covers Copilot sessions associated with a repository and updated within the last seven days
Session sharing on GitHub.comOne user's synced session to people with access to the repositoryA view of prompts, responses, and file changesPrivate unless explicitly shared; sharing grants viewing, not steering or modifying
Copilot Memory (repository facts, user preferences)Feature to feature within a repository or user scopeFacts validated against code, and stated preferencesRepository facts: citations the current branch no longer substantiates. User preferences (Business and Enterprise plans): a different active billing entity. Both: automatic deletion when unused (retention is covered in Implement agent memory strategies)
Instruction files (AGENTS.md, *.instructions.md)Every future session in the repositoryDurable project conventions and path-scoped rulesGoing stale, or contradicting another instruction file with no guaranteed load order

Decision tree

no yes no yes no yes Must the state move between jobs of one run, or come from an earlier run? Must the work resume in another session, editor, or environment? Is it a standing rule, or a repository fact that later sessions may reuse? upload-artifact plus a named download, ordered by needs; across runs: a token and run identifier Conversation: hand off, open, or sync the session Upgrade task state: commit its state folder Rules: instruction files Repository facts: Copilot Memory (re-checked before use) Someone else only needs to see it: share the synced session for viewing, or export it (Export Chat JSON, /share file)

Cheat sheet

  • Upload and download artifacts to pass agent state files between jobs
  • Order artifact consumers after the producing job with needs
  • Use upload paths and exclusions to bound a state handoff
  • Download a named artifact when a consumer needs one specific state package
  • Set the artifact download path when the consuming tool expects a specific directory
  • Account for per-artifact directories when downloading every artifact in a run
  • Provide authorization and run identity when retrieving state from another workflow run
  • Publish transformed state as a separate immutable artifact
  • Treat an artifact digest warning as an integrity discrepancy, not proof of a valid handoff
  • Reuse repository memories only after checking their evidence against the current branch
  • On Business and Enterprise plans, only the current active billing entity's preferences are retrieved
  • User preferences are checked for continued applicability rather than validated as code facts
  • Read expires_at to determine when a saved state artifact is scheduled for deletion
  • A retained artifact can still be manually deleted before its expiration date
  • Deleting a workflow run also deletes the artifacts that carry its agent state
  • Repository read access is sufficient for an authenticated reviewer to download state artifacts
  • Commit the upgrade state folder so the branch carries it across environments
  • Export a CLI session to a file for an explicit context handoff
  • Export a VS Code chat session as JSON to preserve its prompts and responses
  • Use external-session discovery to continue supported local CLI work in VS Code
  • Separate conversation history does not imply separate working files
  • Submit related review comments together so Copilot processes coherent feedback
  • Use applyTo to keep file-specific rules from becoming repository-wide context
  • Use root AGENTS.md for a common instruction set across compatible coding agents
  • Resolve conflicting instruction files rather than relying on file-loading order
  • Inspect instruction references and diagnostics when expected context is missing
  • Use /instructions to inspect and toggle the CLI's active instruction files
  • Account for feature-specific memory consumption when moving between CLI and code review
  • Reference reusable instruction files to reduce divergent copies of the same rules
  • Review shared guidance as the codebase changes and remove obsolete instructions
  • Use native handoff to carry conversation context while changing the execution target
  • Check sync settings and policy before expecting session history on another device
  • Explicit session sharing gives repository collaborators visibility rather than control

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

References

  1. Store and share data from a workflow
  2. Copilot Memory
  3. Customize AI responses with custom instructions
  4. Context engineering guide
  5. Download workflow artifacts
  6. REST API endpoints for GitHub Actions artifacts
  7. Remove workflow artifacts
  8. Manage Copilot Memory as an administrator
  9. Manage agent sessions
  10. Copilot CLI command reference
  11. Session history
  12. GitHub Copilot upgrade overview
  13. Get the best results from Copilot cloud agent
  14. Add repository custom instructions for GitHub Copilot
  15. Add custom instructions to Copilot CLI