Skip to content

Copilot CLI & app

Terminal window
agent-mem setup copilot --write

Writes ~/.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:

Eventagent-mem does
sessionStartbriefing, progress lines
subagentStartbriefing for the subagent
userPromptSubmittednew turn, rules, confident matches
preToolUserule note or deny, file history
postToolUserecord, recipes, fix hints, file history (when nothing else was said)
postToolUseFailurethe failure, fix hint
errorOccurredrecorded as a failed tool named error
agentStopthe answer, read from the transcript; close the turn
subagentStopthe subagent’s answer
preCompactrecorded
sessionEndclose, a short summary
  • 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 of session-state/<id>/events.jsonl and 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.
  • toolArgs is an object since CLI 1.0.83 and a JSON string before; both are read.
  • Hook output limits. postToolUse takes 10 KB, sessionStart 10 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_search and mem_get.
  • Compaction. Copilot ignores context before compaction and starts no session after it; the essentials come back with the next prompt.

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.

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.

Terminal window
COPILOT_HOME=<private temp> copilot -s --no-custom-instructions --disable-builtin-mcps --model auto --auto-tier efficiency

A 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.

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.