Part of the series Agent Harness Updates · Part 5 of 5
pi 1.7.0 tested: sessions come back after a terminal restart, with their restrictions, and install telemetry is gone
Short answer: pi 1.7.0 (released 2026-11-27 UTC) changes three things.[1] It supports the Program Resume Protocol (OSC 7577, a terminal escape-sequence protocol): when the terminal sets OSC7577_TOKEN, pi reports the command that resumes the session, and the terminal runs it after a restart. That command repeats the restriction flags pi was started with, such as --tools, --no-extensions and --skill, and the token no longer reaches any process pi starts.[2] The anonymous install report to /api/report-install is gone, with the enableInstallTelemetry setting and PI_TELEMETRY. And changing the thinking level on GitHub Copilot’s Claude 5.x and GPT-6 models no longer throws away the prompt cache.
| Your situation | What to do |
|---|---|
| You want to upgrade | npm i -g @earendil-works/[email protected]; pi --version should print 1.7.0 |
| You care what pi sends out | 1.7.0 no longer calls /api/report-install, but it still asks pi.dev/api/latest-version at startup and downloads fd from GitHub if it is missing. For zero requests, set PI_OFFLINE=1 |
You had set enableInstallTelemetry: false | In 1.6.1 that switch also turned off the attribution headers sent to OpenRouter, NVIDIA NIM and OpenCode. 1.7.0 removed the setting, and those headers are now always sent |
| You use Rex or another OSC 7577 terminal | Following the official docs, write one trust rule per flag combination. A command no rule matches comes back as a plain shell |
You keep per-project configs with PI_CODING_AGENT_DIR | Upgrade. The 1.7.0 exit hint includes --agent-dir; the 1.6.1 hint fails with No session found in another shell |
| You use Claude 5.x / GPT-6 on Copilot | Just upgrade. cacheWarming defaults to idle, so Copilot’s Claude models are now kept warm too; set it to "off" if you do not want that |
| You run your own Anthropic-compatible endpoint | Turn on supportsMidConvoEffort under compat in models.json, but only if your upstream supports it. 1.6.1 already honours the field |
What changed in 1.7.0
The items that affect harness behaviour:[1]
- Session resume (added). In interactive mode with
OSC7577_TOKENset, pi reportspi --session <id>through OSC 7577, plus the restriction and resource flags it was started with, as typed. pi deletes the token from its environment at startup. --agent-dir <dir>(added). The command-line form ofPI_CODING_AGENT_DIR. With a non-default config directory, the exit hint and the OSC 7577 report include it.- Install telemetry (breaking removal).
/api/report-install, theenableInstallTelemetrysetting (with the SDK’sgetEnableInstallTelemetry()/setEnableInstallTelemetry()) andPI_TELEMETRYare removed. - Copilot prompt cache. Changing the thinking level keeps the cache on supported Claude 5.x and GPT-6 models; supported Claude 5.x models also keep it when tools change; Copilot’s Claude models support cache warming; GPT-5.3 Codex and MAI-Code receive mid-conversation system messages.
- Image generation in codemode. Radius image generation, plus an optional
{ aspectRatio, size }third argument tomodels.generateImages()for OpenRouter image models. - Default models. The two Cloudflare providers now default to
@cf/zai-org/glm-5.3,ant-lingtoLing-3.1-flash, and Qwen Token Plan’sqwen4-max-previewbecameqwen4-max.
This post covers the first four. Image generation needs real Radius or OpenRouter accounts and was not tested.
Why resuming a session needs a terminal protocol
When a terminal crashes, updates or the machine reboots, the pi inside it dies. The session survives in a jsonl file under sessions/, and pi --session <id> picks it up again. What is missing is someone who knows which command to run, and where. Terminals like Rex can relaunch programs after a restart, but the program has to tell them the command first.
The obvious way is an agreed escape sequence. But pi is not the only thing writing to the terminal: a file you cat, a log, an ssh session can all carry bytes in the same format. A terminal that trusted them would let a malicious file run a command as you after the next restart.
OSC 7577 solves this with a token. The terminal puts a random token in the environment when it starts the shell, and a program signs its report with it as sha256(body:token). A comment in pi’s implementation notes that the spec deliberately uses plain SHA-256 with the token appended rather than an HMAC, so that shell scripts can report with sha256sum.[2][3] Content that merely passes through has no token, so its mac fails and it is ignored.
A valid signature proves the command came from a process holding the token, not that it should run. So the terminal has a second gate, trust rules. Rex only resumes command shapes its rules list, such as pi --session <uuid> or pi --session <uuid> -t read,grep,find,ls. A correctly signed command with an unlisted shape comes back as a plain shell after the restart.[2] The token stops outside content posing as a program; the rules stop a program registering a command you did not expect.
It follows that only the reporting program may hold the token. pi starts bash, editors and extension processes; if they inherited the token, they could replace pi’s command or register their own, and a command registered by a child with few rights would later run with your full rights. So pi 1.7.0 calls takeProgramResumeToken() at the very top of main(), before any child process starts, and runs delete process.env.OSC7577_TOKEN as soon as it has read the token. Print, JSON and RPC modes never report, but they delete the token as well.
The sequence pi writes to the terminal
Setup: Linux x64, 1.6.1 and 1.7.0 in separate directories, fresh HOME, XDG_* and PI_CODING_AGENT_DIR per run. Model requests went to a local mock server that returns fixed replies and issues a bash tool call on request; no real account was used. pi ran in a real pseudo-terminal with OSC7577_TOKEN=tok-abc123, and the raw output was decoded afterwards.

The script was: start, choose Trust at the trust prompt, send one message, let the model call bash once, press Ctrl+D twice. 1.7.0 wrote two OSC 7577 sequences during that run:

The first appears after the first message; before that the session has no file to resume. On the wire it is ESC]7577;pid=…:time=…:argv=…:cwd=…:mac=…ESC\, with every argv element and the cwd base64-encoded, and the mac checks out when recomputed with tok-abc123. Decoded, argv is pi --agent-dir <config dir> --session <id> --tools read,bash --no-extensions --skill ./skills/demo --system-prompt "You are terse.", and cwd is the start directory.
The second is clear=1 on Ctrl+D: you quit on purpose, so pi withdraws the command. With SIGHUP instead, which is what a closing terminal sends, only the first report appeared and the command stayed with the terminal. Without OSC7577_TOKEN, 1.7.0 writes no OSC 7577; 1.6.1 never does.
Started as pi -t read,bash -ne, the report contains -t read,bash -ne, not long names. That is deliberate: the terminal compares the report with the process command line, so -t read must stay -t read and ./ext.ts must stay relative.[2] Trust rules therefore have to match each combination as typed, and Rex’s flags tables do not work for pi yet because Node overwrites the command line Rex checks, so each combination needs its own rule.[2]
The protocol has limits of its own. pi sends clear=1 instead when a command has control characters, a relative program or cwd, more than 64 arguments, or would exceed 2048 bytes, so the terminal never resumes an older command in its place.[3]
To see the sequence yourself you need no OSC 7577 terminal. Record pi’s raw output in any pseudo-terminal with some token set, send a message, quit, and decode:
import re, base64, hashlib, sys
raw, token = open(sys.argv[1], "rb").read(), sys.argv[2]
for m in re.finditer(rb"\x1b\]7577;(.*?)\x1b\\", raw):
body, mac = m.group(1).decode().rsplit(":mac=", 1)
ok = hashlib.sha256(f"{body}:{token}".encode()).hexdigest() == mac
fields = dict(kv.split("=", 1) for kv in body.split(":"))
argv = [base64.b64decode(x).decode() for x in fields.get("argv", "").split(",") if x]
print("mac ok" if ok else "mac mismatch", argv or fields)
A matching mac means the sequence came from the token holder, which in 1.7.0 can only be pi. Compare the decoded argv with the exit hint: the difference is exactly the repeated flags.
The token no longer leaks to child processes
In the same session, the mock model had the bash tool run env | grep -c OSC7577_TOKEN; echo TOKEN_IN_CHILD=${OSC7577_TOKEN:-absent}.


Under 1.7.0 the count is 0. Under 1.6.1 it is 1 and the child reads tok-abc123. --tools or --no-extensions change nothing, and the tool_result the mock received matches.

1.6.1 never reports, so the leak may look harmless. But in an OSC 7577 terminal, any script run through pi and any command the model writes could use the token to register a command the terminal runs after a restart. 1.7.0 keeps the token inside pi, and the terminal hands one only to the first process.
Why the resume command repeats the flags as typed
After a restart the terminal runs only argv in cwd. pi’s environment does not come along, and that decides what the command must contain.
Start with the config directory. For a session started with PI_CODING_AGENT_DIR, 1.6.1 prints pi --session <id> on exit. Run that in a shell without the variable and pi looks in the default ~/.pi/agent, which ends in No session found matching '…'. 1.7.0 prints pi --agent-dir <dir> --session <id>, and under the same conditions the session came back with all seven earlier messages.

Not finding the session is the mild outcome, since you notice. The release notes describe a worse one: the session came back with the default directory’s settings and auth, the wrong account, and no error.[1] Per-project profiles, typically a shell function that sets PI_CODING_AGENT_DIR for one directory tree, are most affected.
Next, the restriction flags. The source has an allowlist of what gets repeated: --tools/-t, --exclude-tools, --no-tools, --no-builtin-tools, --extension/-e, --no-extensions, --no-mcp, --skill, --no-skills, --prompt-template, --no-prompt-templates, --theme, --no-themes, --no-context-files/-nc, --system-prompt, --append-system-prompt, --approve/-a, --no-approve and --models, plus their short forms.[2] Model, thinking level and session name live in the session file and are not repeated; secrets such as --api-key are left out.
Without them, it depends on the flag. A session started with --tools read,bash --system-prompt "You are terse." and resumed with a bare pi --session <id> still sent only read and bash, with the same system prompt; both were recorded with the session. Context files were not. With an AGENTS.md in the project and the session started with -nc (--no-context-files), the first request lacked it. After resuming with the exit hint, the second request contained it. Resuming again with -nc, as the OSC 7577 report would, the third request still contained it, because the previous resume had written it into the history.

That is the point to remember: drop a restriction on one resume, and what it kept out can stay in the session even after the flag returns. Extensions work the same way. Drop --no-extensions and the resumed process loads extension code, which is mostly what the release notes mean by “possibly more access”.[1] So 1.7.0 hands these flags to the terminal instead of relying on your memory.
The command printed on exit is unchanged and does not repeat the flags.[1] If you paste it yourself, add the restrictions back.
One more boundary: if pi was started with flags and you open a session from another directory, pi withdraws the command, because relative paths such as ./skills/demo would point elsewhere.[2] This comes from the source and docs; I did not test it.
Install telemetry: what was removed and what remains
In 1.6.1 the report lives in interactive mode. With no lastChangelogVersion in settings, or after an upgrade with new changelog entries, pi sends GET https://pi.dev/api/report-install?version=1.6.1 with the User-Agent pi/1.6.1 (linux; node/v24.22.1; x64). No cookie, no machine ID, only version and platform. PI_OFFLINE, enableInstallTelemetry: false or PI_TELEMETRY=0 skip it.
All HTTPS went through a local proxy that terminated TLS with a throwaway CA, logged the request line and answered 204.

1.6.1 sent report-install on a fresh install and on an upgrade from 1.6.0, and not with the setting off or PI_TELEMETRY=0. 1.7.0 sent none on a fresh install, an upgrade from 1.6.1, with enableInstallTelemetry: true, or with PI_TELEMETRY=1. The leftover key is silently ignored.
In print mode, 1.6.1 with a fresh config dir and the setting true made no requests at all, not even the version check, since both hang off interactive startup. pi -p in CI never sent the report.
Two requests remain in both versions: the version check pi.dev/api/latest-version, and github.com/sharkdp/fd/releases/latest when pi fetches the missing file finder fd. PI_SKIP_VERSION_CHECK=1 removes the first; PI_OFFLINE=1 removes both, giving zero requests on both versions. It also disables the model catalog refresh from pi.dev.[4]
One change is missing from the release notes. In the 1.6.1 settings docs, enableInstallTelemetry controls two things: the install report and “selected provider attribution headers”.[5] In the source, turning it off made getClientIdentity() return attribution: null. In 1.7.0 that function hard-codes attribution: PI_ATTRIBUTION.

pi treats a target as OpenRouter when the provider is named openrouter or the baseUrl contains openrouter.ai, so a custom provider at http://127.0.0.1:18787/openrouter.ai shows the headers. With the setting false, 1.6.1 sent no attribution headers. 1.7.0 with false still sent HTTP-Referer: https://pi.dev, X-OpenRouter-Title: pi and X-OpenRouter-Categories: cli-agent. According to the source, NVIDIA NIM gets X-BILLING-INVOKE-ORIGIN: Pi, OpenCode gets x-opencode-client: pi, and other providers get no attribution headers. The headers identify pi, not you. Still, if you turned the setting off so nothing would be tagged, that switch is gone. Headers in models.json override defaults per the docs, but setting them to null failed validation, and I found no configuration that removes them.
Copilot caching: a few switches turned on in the catalog
With adaptive thinking, Anthropic requests carry the effort in the top-level output_config.effort. The prompt cache matches a prefix in the order tools, system, messages, and a changed top-level parameter breaks the match, so switching from low to high makes the next request pay the uncached rate for the whole prefix.
pi’s answer is to keep the top level fixed. For a model with supportsMidConvoEffort, the top-level output_config.effort is always low, and thinking gains block_binding: { prefix_mismatch_behavior: "drop_block" }. The real effort goes at the end of the message list as an empty system message, {"role":"system","content":[],"output_config":{"effort":"high"}}, and the request carries the betas mid-conversation-output-config-2026-07-01 and thinking-binding-controls-2026-08-01.[6] It is low because organizations can cap effort and reject any request containing a level above the cap.
Tool changes work the same way. With supportsMidConvoToolChanges, the top-level list stays fixed as the initial tools plus a placeholder, __pi_deferred_placeholder__; later tools go into tool_addition blocks in mid-conversation system messages, removals into tool_removal, with the inline-tools-2026-09-15 beta.
GPT-6 uses the OpenAI Responses API: there, supportsMidConvoEffort leaves reasoning.effort alone and appends a configuration_update input item.[6] I did not test that API; this rests on the docs.
All of this already existed in 1.6.1. 1.7.0 changed the GitHub Copilot model catalog. Diffing both versions’ github-copilot.json: 10 Copilot Claude models gained promptCache: { short: 300, long: 3600 }; Claude Fable 5.1, Fable 5.2, Haiku 5.5, Opus 5.5 and Sonnet 5.5 gained supportsMidConvoEffort; those five plus Fable 5 and Opus 4.8 gained supportsMidConvoToolChanges; 7 GPT-6 family models gained supportsMidConvoEffort; GPT-5.3 Codex and three MAI-Code models gained supportsMidConvoSystemMessages.
Copilot needs a real login, so I did not test that route. Instead I configured three Anthropic-compatible models on the mock: no new switches, supportsMidConvoEffort, and that plus supportsMidConvoToolChanges. In one session I ran a turn with --thinking low, continued with --thinking high, and compared the request bodies.

Without the switch, only the top-level output_config.effort changed, from low to high. With supportsMidConvoEffort, all four top-level fields stayed the same and the first turn’s messages were a strict prefix of the second’s; the additions were the reply, the new user message and a trailing system message with effort: high. 1.6.1 produced the identical shape, confirming the 1.7.0 change is catalog data.
The tool test is clearer still. Switching from --tools read,bash to read,bash,edit, the effort-only model’s tools array changed, and since tools come first the common prefix shrank to 1,503 of 5,114 characters. With supportsMidConvoToolChanges, tools stayed [read, bash, placeholder] and edit arrived as a tool_addition.
This shows only that pi’s prefix stays stable; actual cache hits on Copilot would show as cached tokens on a real bill, which I cannot measure. For how the request prefix affects caching, compare the earlier OpenCode installment: OpenCode 2.3.2 and the GPT-6.2 prompt cache prefix.
Cache warming is a separate matter. The cacheWarming setting defaults to idle: during runs, and for up to 30 minutes between them, pi sends warming requests for models that declare a cache lifetime, provided it estimates at least $0.05 in avoided cache-miss cost.[5][7] 1.7.0 gave Copilot’s Claude models a promptCache lifetime, so they now qualify. Warming usage counts toward session totals; I did not verify how Copilot bills it. Set cacheWarming to "off" to stop it, or enable notices.cacheWarming to see the cost.
How the other harnesses resume sessions
None of the installed packages of Claude Code 2.1.332, Codex 0.172.0, OpenCode 2.4.2, Gemini CLI 0.71.1 and Qwen Code 0.29.0 contains OSC7577_TOKEN or ]7577;. Of these six, only pi brings a session back automatically after a terminal restart.
All of them have a manual resume entry. Claude Code has -r/--resume [id] and -c/--continue, with --fork-session to branch. Codex has codex resume [id] or --last. OpenCode has -s/--session <id> and -c, with --fork. Gemini CLI has --resume latest or an index, plus --session-file. Qwen Code has -r <id>, -c and --fork-session.[8]
They differ in how restrictions carry over. Codex’s resume subcommand accepts -s/--sandbox, -a/--ask-for-approval and --add-dir itself, so every resume declares permissions again. Claude Code 2.1.332 has --system-prompt-snapshot, on by default: the system prompt is rendered on the conversation’s first request and recorded, and every later request and resume sends the record as-is, even if a later launch passes a different --system-prompt, until the conversation is compacted.[8] That matches pi, where the system prompt travels with the session, but permission and tool flags are still yours to retype. OpenCode, Gemini CLI and Qwen Code resume commands accept flags like --agent or --core-tools, and nothing remembers them for you.
For default usage statistics, based on the docs or help text shipped in each package: Gemini CLI’s privacy.usageStatisticsEnabled defaults to true; Qwen Code’s usageStatisticsEnabled is on by default; the Claude Code binary contains DISABLE_TELEMETRY and CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC switches; Codex’s help text says app-server analytics are off by default and must be enabled in the analytics section of config.toml, except for first-party clients such as the VS Code extension; I did not check OpenCode. In pi 1.7.0 what remains is the version check and catalog refresh, both off with PI_OFFLINE=1.
For pi as a whole, see Pi 1.0: folding MCP into Codemode in a minimal coding-agent harness and what a durable harness protects, centred on Pi Durable. The previous installment covered Claude Code 2.1.332’s MCP skills and PreSkillShellCommand hook, and Claude Code’s overall structure is in Inside Claude Code’s agent harness.
Recommended setup
- Upgrade to 1.7.0 whether or not you use an OSC 7577 terminal. Token stripping and
--agent-dirare fixes and need no configuration changes. The one thing you may dislike is the lost attribution switch; OpenRouter users should read item 4 first. - On Rex, settle on a few ways of starting pi and write one trust rule for each, with flag order and short or long forms exactly as you type them. When no rule matches, the terminal gives you a plain shell rather than resuming without the flags, which is the safe way to fail.
- When you resume by copying the exit hint, add your restriction flags back, especially
-ncand--no-extensions. Miss them once, and what they kept out may stay in the session. - If outbound requests matter to you,
PI_OFFLINE=1is more reliable than any single switch. If you route through OpenRouter and do not want attribution headers, there is currently no configuration that removes them. - Copilot users should check the warming decision in
/sessionafter upgrading, and setcacheWarming: "off"if they do not need it.
What was tested and what was not
Tested (Linux x64, isolated directories per run, local mock model server and local HTTPS proxy, no real account, no outbound requests):
- OSC 7577: raw sequences, mac check, report and
clear=1timing, SIGHUP, no token, long and short flags, 1.6.1 for comparison. - Child environment:
OSC7577_TOKENinside the bash tool on 1.6.1 and 1.7.0. - Resume: both exit hints without
PI_CODING_AGENT_DIR; tools, system prompt andAGENTS.mdon a flagless resume. - Telemetry: startup requests across install, upgrade, setting and environment variables; OpenRouter attribution headers.
- Prompt cache: request bodies with and without the effort and tool-change switches; a diff of both Copilot catalogs.
- Other harnesses:
--helpand installed packages.
Not tested:
- An actual Rex restart and how its trust rules match.
- The withdrawn report after opening a session from another directory with flags (source and docs only).
- The GitHub Copilot route itself, real cache hits, and the actual requests and billing of cache warming.
- Radius and OpenRouter image generation in codemode, and the default model changes.
- Real session resume in the other harnesses and the telemetry requests they actually send.
References
- pi v1.7.0 release notes: https://github.com/earendil-works/pi/releases/tag/v1.7.0 ↩
- pi docs, Terminal setup (Program resume): https://github.com/earendil-works/pi/blob/v1.7.0/packages/coding-agent/docs/terminal-setup.md#program-resume ↩
- Program Resume Protocol (OSC 7577) spec: https://www.superlogical.com/rex/docs/build/program-resume ↩
- pi docs, Environment variables and Choose a Model: https://github.com/earendil-works/pi/blob/v1.7.0/packages/coding-agent/docs/environment-variables.md ↩
- pi docs, Settings (v1.6.1 and v1.7.0): https://github.com/earendil-works/pi/blob/v1.6.1/packages/coding-agent/docs/settings.md, https://github.com/earendil-works/pi/blob/v1.7.0/packages/coding-agent/docs/settings.md#model-and-thinking ↩
- pi docs, Models configuration (
anthropic-messagescompat fields): https://github.com/earendil-works/pi/blob/v1.7.0/packages/coding-agent/docs/models-configuration.md; Copilot caching issue: https://github.com/earendil-works/pi/issues/12316 ↩ - pi docs, Prompt Cache Lifetimes: https://github.com/earendil-works/pi/blob/v1.7.0/packages/coding-agent/docs/models.md#prompt-cache-lifetimes ↩
--helpof each CLI: Claude Code 2.1.332, Codex 0.172.0 (codex resume --help), OpenCode 2.4.2 (opencode run --help), Gemini CLI 0.71.1, Qwen Code 0.29.0 ↩