# GitHub Copilot

> Import GitHub Copilot CLI sessions, Copilot Chat from VS Code-family editors, and Copilot coding agent sessions on request.

Copilot's terminal, editor, and cloud coding agent histories are stored in
different places. Import the CLI and editor sources together, and import coding
agent sessions from GitHub when you want them.

Copilot Desktop, SDK runtimes, Remote Control, and GitHub-hosted Claude or
Codex agents are separate surfaces. The routes below do not establish support
for those histories; see the [coverage reference](https://www.hansard.dev/reference/import-coverage/).

## Source IDs

| Source                | Use it for                                                                                                                        |
| --------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
| `copilot-cli`         | GitHub Copilot CLI session events and workspace details in `~/.copilot/session-state`.                                            |
| `copilot-ide`         | Copilot Chat sessions from VS Code and other VS Code-family editors.                                                              |
| `copilot-agent-cloud` | Copilot coding agent sessions, read from GitHub. Runs when you ask for it or turn it on in **Settings → Imports → Cloud agents**. |

## How the import works

For the Copilot CLI, Hansard reads each session's event stream and its saved
workspace state. For editor chat, it reads the Copilot chat records that VS
Code-family editors keep in their workspace storage, in both the JSON format
used through VS Code 1.108 and the log format used since 1.109. Each source
rebuilds messages and any tool calls, edits, model, and usage in the order the
tool wrote them, and adds only details that belong to the same session or
workspace.

Current VS Code request token counts and response timestamps are supported.
The importer rejects incomplete mutation logs and retries after the file is
complete. Chat documents have a 128 MiB read limit. The previous archive
remains available when a source cannot be read.

The editor route does not discover Copilot extension `transcripts` files,
VS Code `agentSessionData` databases, or JetBrains chat databases. JetBrains
CLI-backed sessions can use the CLI store, but this does not establish full
JetBrains coverage. AI credits, cache details, and per-model aggregate totals
remain raw evidence when the chat document records them.

The coding agent import reads your sessions from GitHub and joins each
session's prompt, transcript, premium request charge, repository, and pull
request by session ID. Cost appears as premium requests rather than tokens,
because that is how GitHub bills the coding agent. Each retry on the same pull
request stays its own session. Tool arguments or usage that GitHub does not
return stay empty. Importing again updates the same sessions.

## Import and keep current

**Import now**

```sh
hansard import --sources copilot-cli,copilot-ide --since all
hansard import copilot-agent-cloud --since all
hansard index rebuild
```

The coding agent import uses a GitHub token from `GH_TOKEN`, `GITHUB_TOKEN`,
`copilot.token` in Hansard's config, or the GitHub CLI's saved sign-in. It
only reads from GitHub, and Hansard never stores the token. Without a token,
it prints setup instructions instead of failing.

**Keep current**

With **Automatic** source selection, the watcher already includes
`copilot-cli` and `copilot-ide`. With a **Custom** list, enable them.
The watcher picks them up within 30 seconds:

```sh
hansard config sources enable copilot-cli,copilot-ide
```

To keep coding agent sessions current, turn on **GitHub Copilot coding agent**
in **Settings → Imports → Cloud agents**. The watcher then refreshes it every
six hours. Otherwise, run the command again when you want newer sessions.

## Review the import in the app

1. When the import finishes, open **Conversations** and select **Filter & sort**.
2. Set **Source** to **GitHub Copilot CLI, GitHub Copilot in VS Code, or GitHub Copilot coding agent** and set **Time** to the window you imported. Use **Folder** to narrow the list when you use this harness in several projects.
3. Select a conversation to check its messages, tool calls, files, commits, model, and token usage.

To keep archiving new sessions from a local harness, open **Settings → Imports**. **Automatic** follows every supported harness installed on this computer. **Custom** lets you turn individual harnesses on or off. Cloud sources and account exports never run from here; each needs its own import command. If a conversation you expect is missing after you reset the filters, run the import command on this page again with `--explain-skips` where the source supports it.

## What Hansard preserves

- CLI messages, tool calls, session events, model routing details, workspace
  data, related session files, tokens, premium request multipliers, and AI
  credits.
- CLI event IDs, native message IDs, originating-message relationships, and
  explicit zero counters. A nonzero shell exit is an error even when Copilot
  reports successful tool dispatch; both values remain available.
- Editor chat messages, thinking, tool activity, terminal commands, file edits,
  titles, timing, and diff statistics when the editor recorded them.
- Coding agent prompts, transcripts when available, the model, the premium
  request charge, and the pull request.

## Known limitations

- CLI and editor model attribution uses recorded response or request models.
  CLI model selections and the editor's current composer selection remain
  separate from historical models. CLI effort comes from the reply or a
  chronological selection matching its recorded model; resume clears earlier
  effort.
- CLI usage from `session-store.db` replaces overlapping shutdown totals.
  Missing and null counters remain unknown. The local synthetic CLI trial
  verifies the recorded counters, not hosted billing.
- VS Code releases before 1.109 do not record token usage for each request.
- VS Code-family editors drop most tool arguments when they save chat.
  Terminal commands, confirmations, todo lists, and subagent calls keep more
  detail.
- The coding agent reports premium requests or AI credits instead of tokens, so
  its sessions have no token usage or spend.
- GitHub does not document the coding agent's transcript endpoint. When a
  transcript is unavailable, the session imports without it and shows a note.
  To skip transcripts, set `imports.copilotAgentCloud.includeTranscripts` to
  `false`.
- Editor chats answered by a chat participant other than Copilot are not
  imported as Copilot sessions.

## Refresh an existing archive

Reimport to refresh CLI model attribution, message relationships, zero counters,
shell exit status, and the preserved usage-ledger binding. Older enriched CLI
archives without that binding require a reimport before rebuilding from raw.

```sh
hansard import --sources copilot-cli,copilot-ide --since all
hansard import copilot-agent-cloud --since all
hansard index rebuild
```
