A short walkthrough of a terminal coding agent's session model argues for an unglamorous discipline: start the agent in the directory you intend to work in, because that directory — not a session title — is what the tool uses to find your conversation again. The claim is worth checking, because the same working directory governs configuration discovery, resource discovery and the trust gate, and because the easiest way to lose a session is a command that looks read-only.
What the documentation specifies
Sessions are stored on disk under a per-user agent directory, grouped by working directory. Each session records the working directory it was created in, and never changes it. The documentation describes the working directory as controlling three things at once: project configuration, resource discovery, and session grouping. The folder is therefore not a convenience for a file picker. It is the session's identity key.
That makes the resume surface narrower than it looks:
--continue/-ccontinues the most recent session for the current directory. Run it one folder over and it finds a different session, or none.--resume/-ropens a chooser across sessions instead of assuming the latest one.--session <path or id>addresses one session explicitly, and is the only form that does not depend on where you are standing.--forkbranches from an existing session, and is documented as not combinable with--session,--continue,--resumeor--no-session.--session-idnames a session at creation;--no-sessioncreates none at all.
Storage is relocatable: a session-directory flag, an equivalent environment variable, a settings key, and a flag that moves the whole agent directory. That matters mainly for teams who want sessions on a synced or per-repository path rather than in a single home-directory pile.
The footgun the flags imply but the docs do not name
Two behaviours reported from practice are not covered by the published reference, and they are the part worth testing before you rely on any resume habit.
The first: a plain non-interactive run — the one-shot "print" invocation people use inside scripts, pre-commit checks and CI — also writes a session, and it is then the most recent session for that directory. The next --continue reopens the throwaway, not the long conversation you meant. If that is true in your version, the remedy is already in the flag list: give scripted invocations --no-session, or pin the real work with an explicit session id.
The second: naming a session is not the same as persisting it. A session that is titled but never advanced can leave no file behind, so a name is not a handle you can count on. Addressing a session by its path or id is.
Neither claim is in the reference, so both belong in the category of things to verify locally rather than cite.
Why the working directory also decides what the agent trusts
The same key carries the security boundary. The agent has a trust gate on first use of a project: approval flags exist to grant or refuse it, and project-local server configuration is read only for projects already trusted. Starting the agent in a parent directory, or in a home folder, therefore does not merely scatter sessions — it changes which project configuration and which tool definitions are in scope, and it can place an untrusted tree inside a trusted one.
Context files are discovered the same way (the agent reads a conventional pair of markdown context files, with a flag to disable them), but the documentation does not state which directories are searched or whether discovery walks upward. Teams that keep context files at a repository root and work from subdirectories should establish that empirically.
One recovery path is documented and worth knowing: if the folder a session was created in no longer exists, the agent offers to continue, fork, or cancel — and does not remember the choice. Moving or renaming a project directory is therefore a per-resume prompt forever, not a one-time migration.
What to take from it
The practical rule is small and cheap: one working directory per piece of work, entered before the agent starts; explicit session ids for anything you intend to come back to; --no-session on every scripted invocation; and a deliberate decision about where session storage lives before the pile becomes the problem.
The larger point is about where a tool keeps identity. Putting it in the filesystem path makes resume predictable without a database and makes configuration, resource and trust scoping fall out of the same key — at the cost of making cd a semantically loaded command. Any agent harness that stores conversation state has to choose a key. A path is a defensible choice, but it is only safe if every entry point respects it, and a non-interactive run that quietly becomes the latest session is exactly the entry point that does not.
Review checklist
Run the one-shot non-interactive form in a scratch directory, then
--continuethere. Did you get your conversation or the one-shot?Grep your scripts, hooks and CI for agent invocations without a no-session flag.
Decide now whether session storage is per-user or per-repository; changing it later means orphaning the existing grouping.
Confirm, in your version, which directories context-file discovery searches.
Check whether any project you work in sits inside an already-trusted parent.