Copilot CLI & app
Connect
Section titled “Connect”agent-mem setup copilot --writeWrites ~/.copilot/hooks/agent-mem.json (a file of its own) and adds the MCP server to
~/.copilot/mcp-config.json:
"agent-mem": { "type": "local", "command": "/Users/you/.local/share/uv/tools/agent-mem/bin/agent-mem", "args": ["mcp"], "tools": ["*"] }Copilot CLI and the Copilot app (macOS) both read hooks from ~/.copilot/hooks. COPILOT_HOME moves ~/.copilot.
Copilot passes the event name as an argument (agent-mem hook copilot sessionStart) and has a bash and a
powershell form of each command, both with timeoutSec: 10:
| Event | agent-mem does |
|---|---|
sessionStart | briefing, progress lines |
subagentStart | briefing for the subagent |
userPromptSubmitted | new turn, rules, confident matches |
preToolUse | rule note or deny, file history |
postToolUse | record, recipes, fix hints, file history (when nothing else was said) |
postToolUseFailure | the failure, fix hint |
errorOccurred | recorded as a failed tool named error |
agentStop | the answer, read from the transcript; close the turn |
subagentStop | the subagent’s answer |
preCompact | recorded |
sessionEnd | close, a short summary |
What Copilot does differently
Section titled “What Copilot does differently”- No
systemMessage. agent-mem writes a{"type": "progress", "message": "…"}line before the JSON; Copilot shows it in its timeline and parses the rest. The session panel appears as progress lines, uncoloured. - No answer in
agentStop. Only the transcript path. agent-mem reads the end ofsession-state/<id>/events.jsonland waits up to 250 ms for the final message, which Copilot writes 50 to 150 ms after the hook starts. - The first prompt arrives before
sessionStart. Memories from this session’s own turns are kept out of its briefing. toolArgsis an object since CLI 1.0.83 and a JSON string before; both are read.- Hook output limits.
postToolUsetakes 10 KB,sessionStart10 MiB; agent-mem caps blocks around tools at 2,400 tokens. - No MCP instructions. Copilot does not pass an MCP server’s instructions to the model, so its briefing has one
more line naming
mem_searchandmem_get. - Compaction. Copilot ignores context before compaction and starts no session after it; the essentials come back with the next prompt.
The Copilot app
Section titled “The Copilot app”Sessions the app runs in its worktrees (~/.copilot/copilot-worktrees/<repo>) are recorded for their repository.
Plain chats in the app, without a repository, are not recorded.
Copilot Chat in VS Code
Section titled “Copilot Chat in VS Code”VS Code (1.142) runs the hooks in ~/.copilot/hooks too, with Claude Code’s payloads, and reads context only from
hookSpecificOutput. agent-mem recognizes these calls, leaves out the progress line there, reads the answer from
VS Code’s transcript, and counts the files of replace_string_in_file and multi_replace_string_in_file.
COPILOT_HOME=<private temp> copilot -s --no-custom-instructions --disable-builtin-mcps --model auto --auto-tier efficiencyA private COPILOT_HOME per call, so the call is not saved as a session in the app and runs none of your hooks,
plugins or MCP servers; config.json is copied in for logins kept there. auto with the efficiency tier works on
every plan, including Free, which refuses fixed models; it resolves to GPT-6-Luna.
Token accounting
Section titled “Token accounting”From ~/.copilot/session-state/<id>/events.jsonl: each session.usage_record’s input minus cache reads, plus output.
Tested with Copilot CLI 1.0.103, the Copilot app 1.1.29 on macOS and Copilot Chat in VS Code 1.142.