Sessions and tools

Use a session

Run panda --scrollback to keep prompts and streamed replies in your terminal’s scrollback. Add --continue to reopen the latest session. Kitty and iTerm2 can also display PNG attachments and tool results inline. Terminal preferences

Run panda "Review this change" in an interactive terminal to send the first prompt immediately and keep the session open for follow-ups. Use panda --print "Review this change" for a single answer. A positional prompt also runs once when a stream is redirected or when you supply a print/JSON-only option such as --no-session.

The interactive prompt starts in Vim Insert mode. Press Esc for Normal mode, use motions such as w, b, 0 and $, and edit with cw, dw or u. Press i to insert again. Enter sends the prompt. Alt-Enter inserts a newline in terminals that report the shortcut. Multiline paste stays in the editor until you submit it.

The full-screen UI renders Markdown as replies stream, including headings, lists, emphasis, inline code and fenced code. Panda uses the same styles and wrapping to render saved Markdown when you reopen a session. Page Up and Page Down scroll the transcript while you edit. Successful file edits show a coloured, numbered before-and-after excerpt with context. The prompt sits between two rules, with the workspace and Git branch, session mode, latest reported input/output token counts, and selected model below it. The lower-left footer shows the Vim mode. Press Esc, type a command such as :q, and press Enter. In either the idle or steering prompt, typing :mo shows :model and :models above the command line. Tab completes the first match and cycles forward, Shift-Tab cycles backward, and Enter runs the displayed command. Esc cancels the command and restores the draft. Existing slash commands still work. The steering prompt shares the idle editor’s Vim motions, operators, and undo history. Set NO_COLOR=1 for monochrome. Use :tools for full tool results.

  • :plan enables directory listing, file discovery by glob, paginated literal and regex search, file reads, skill lookup and conversational clarification. Type :code to enable edits, writes and shell commands.
  • :resume opens a searchable picker for this workspace. Type part of a name, prompt, or reply to see matching sessions and a conversation preview. Use ↑/↓ to preview another result, Enter to resume, or Esc to return. In piped input, bare :resume lists sessions. :resume ID reopens one and displays its transcript and mode. Ctrl-C interrupts an active turn. :quit closes Panda.
  • After an interrupted turn, inspect the workspace and use :ack to close outstanding calls with an unknown outcome. Panda never reruns the old call during resume.
  • Panda loads $PANDA_HOME/AGENTS.md and instructions from the Git root down to the launch directory. Its instructions tool reads the applicable nested files for a workspace path. Panda discovers Markdown skills in workspace and user skill directories. Set PANDA_SKILL_ROOTS to add colon-separated directories.
  • Workspace tools inherit a private scratch home, restricted filesystem access, and a network-denying macOS profile. System commands and Xcode build tools are available. Set PANDA_TOOLCHAIN_DIRS to colon-separated, trusted toolchain installations to grant read access and add their bin directories to the tool PATH.
  • PANDA_HOME defaults to ~/.panda. This private directory holds the SQLite session database, model selection, and any stored credentials. Install Panda outside repositories you let it edit.

Prompt, tools and sessions

Edit results retain the numbered text diff. JSON events and saved sessions also expose firstChangedLine (one-based, null for a no-op) and an ordered patch of replacement strings and half-open UTF-8 byte ranges in the original file.

In plan and code mode, read accepts UTF-8 text files and images. PNG, JPEG, GIF and WebP images can be up to 8 MiB each. Panda recognizes images by their contents and sends the original bytes to the model. Use offset and limit for text line ranges. In Codemode, tools.read({path: "diagram.png"}) returns an image block with type, mimeType, base64 data and a short note. Call image(block) between text(...) calls to select and position the image. Explicit images are saved under .panda/ and their paths appear in the result. Scripts that omit image() retain automatic read attachments. The encoded image budget is 12 MiB per script.

In code mode, shell accepts an optional whole-number timeout from 1 to 600 seconds and defaults to 120 seconds. A timeout or cancellation stops the shell and its process group. A descendant that has left the group can continue running under the same sandbox permissions and can still change workspace files while you review the diff. When combined stdout and stderr exceed 64 KiB, the result includes the exit status, the last 64 KiB and the workspace-relative path to a full log under .panda/. The log stays in the workspace after Panda exits. Use read or Codemode’s tools.read with offset and limit to inspect earlier lines.

In code mode, edit accepts a single {"path":"src/app.rs","old":"before","new":"after"} replacement or a batch such as {"path":"src/app.rs","edits":[{"old":"fn check()","new":"fn verify()"},{"old":" check();","new":" verify();"}]}. Each target must occur exactly once in the original file. Edits may be listed in any order. A valid batch writes the file once and returns one numbered diff. A missing, ambiguous, or overlapping target rejects the entire batch.

To do this In Panda
Attach a workspace file Type @src/main.rs, or @"path with spaces". Press Tab in Insert mode for completions. For large files, ask Panda to read a range of lines.
Send an image Attach a PNG, JPEG, GIF or WebP by path, or use Ctrl-V in Insert mode or :paste for a macOS clipboard image. :detach clears the pending clipboard image. Select a model that accepts images.
Edit a longer prompt Press Ctrl-G in Insert mode. Panda opens the draft in $VISUAL, $EDITOR or vi. Save and close the editor to return.
Recover from a temporary provider failure By default Panda retries a transient failure up to three times before streaming begins. The countdown appears above the prompt. Ctrl-C cancels it. Completed tools are never replayed by the retry.
Redirect an active turn Type a correction and press Enter. Panda delivers it after the current batch of tools finishes. Alt-Enter queues a follow-up after the answer. Alt-Up brings queued text back into the draft.
Copy a reply Use :copy or Ctrl-X in Insert or Normal mode to copy the last completed reply on the active branch as original Markdown. During a turn the command runs when Panda returns to the prompt.
Inspect output Shell output appears as it arrives. During a turn the activity timer sits above the steering prompt. Ctrl-O at the prompt expands tool results, :tool ID toggles one and Ctrl-T shows or hides reasoning supplied by the model.
Run a shell command yourself In code mode, !git status adds the command and result to the conversation. !!git status displays it locally. Both use the workspace sandbox.
Explore another approach Open :tree, type to filter, and select an earlier prompt to edit it in Insert mode. Submit it to start a sibling branch in the same session. To try a revised prompt in a separate session, highlight the prompt and press Ctrl-F. The child opens with the earlier history and the selected prompt ready to edit. Press Enter to send it. In the tree, Shift-L edits the highlighted entry’s label. Submit an empty label to clear it, or press Ctrl-C to cancel. Ctrl-L toggles the labeled-only view and works alongside the text filter. Labels survive Pi JSONL export and import. Enter switches immediately. Press s on a selected entry to summarize the branch you are leaving and carry its findings into the destination. Press Shift-S to guide that summary, then Enter to submit or Esc to return to the same selection. Use / to filter the tree, then ↑/↓ to select or Ctrl-S to summarize the match. Ctrl-C cancels generation. Select a completed answer to continue from it. Esc closes the picker. Both paths survive quitting and resuming. Navigation changes conversation history only. Workspace files keep their current contents. :fork 2 alternative starts a session at the second completed answer. :clone NAME copies the current conversation.
Return to a session :resume ID or :resume NAME opens a session in the current workspace. panda --continue opens the most recently modified session for that workspace. Creating or saving a session makes it current. Browsing and exporting preserve that order.
Manage context :context shows projected bytes, estimated input tokens and the input budget. Before each model request, including after a tool batch, Panda uses the latest reported token usage plus an estimate for new messages. It reserves a quarter of the context window for the reply, capped at 16,384 tokens. An unknown window defaults to 65,536 tokens. :context BYTES sets an additional byte threshold. :compact [instructions] summarizes earlier conversation for the model while preserving the transcript on disk. Use it alone for the default summary or give it a focus, for example :compact Keep the rollout decision and open questions.
Choose a model :models openrouter deepseek filters the provider catalogue. Use :model NUMBER to select a result. Use :effort to choose a reasoning level, or enter it directly with :effort high. :thinking is an alias. Codex choices come from the selected model’s catalogue entry.
Use a Markdown skill Search with :skills QUERY and invoke one with :skill:NAME task. Panda shows the selected path.

Panda first tries a verified extractive handoff for manual, automatic and overflow checkpoints. It uses the optional TYPESAFE_API_KEY for Jev judgments and masks credentials before sending any text. Without a key, or if judging fails, times out or rejects the handoff, a manual or hard checkpoint uses the current chat provider’s summarizer. Panda can defer compaction at the soft threshold until the next clean boundary. Both strategies preserve the branch and save a private recovery transcript only when a new checkpoint commits.

  • :compact [guidance] adopts a checkpoint. :compact preview [guidance] displays the candidate and leaves session history and recovery storage untouched. Esc cancels a preview in the terminal.
  • :compact info and :context report usage, effective thresholds, prompt section estimates and the visible tool declarations. Looking at context makes no judge requests.
  • view_context() returns the same diagnostics. self_compact({note?}) schedules a checkpoint at the next safe boundary. Panda records the note as model-authored data. Both tools follow the selected tool policy, including --tools and --no-tools.
  • Set compaction.softAt, hardAt, cacheAt (percentages) and cacheForMinutes in user or project settings. Their defaults are 50, 70, 70 and 30. The hard threshold is capped at 90% of an effective window of at most 300,000 tokens. A cache duration of zero disables the warm-cache hold. Override one invocation with --compact-soft-at, --compact-at, --compact-cache-at or --compact-cache-for.

The paired synthetic fixtures measure instruction retention, factual accuracy, recoverable pointers, size and request costs. Compaction comparison

To keep recent exchanges verbatim during manual and automatic compaction, set an estimated token budget in $PANDA_HOME/settings.json and restart Panda. This example keeps up to 20,000 estimated tokens.

{"compaction": {"keepRecentTokens": 20000, "modelOverrides": {"deepseek/deepseek-chat": {"keepRecentTokens": 8000}}}}

The active provider/model override takes precedence over the global setting, including an explicit zero. An invocation-level --keep-recent-tokens overrides both.

The verified planner uses a 20,000-token retention target by default and keeps the latest exchange intact, including tool calls and results. It advances older history in groups of up to 400 visible segments. A zero target keeps only the latest whole exchange. Provider fallback preserves the existing retention behavior. A bare manual request can cover all eligible history, and automatic requests use the model-based budget.

Compaction keeps a sorted list of files read and files modified alongside the summary. A successful edit or write moves a path into the modified list. Successful reads, edits and writes inside Codemode count even if the script later throws. The lists survive reopening and Pi JSONL export and import.

If a provider stops for length before using its output allowance, Panda saves the partial reply in the transcript and retries once. It can compact older exchanges before retrying. The retry carries the current prompt and completed tool results forward. Tool calls from a truncated reply never run. If the provider used its full allowance or the token count or limit is unknown, the turn ends with a length error. A follow-up uses the completed conversation.

Panda sends an explicit output limit for supported DeepSeek models and for OpenRouter models with an output limit in the cached catalogue. Refresh the OpenRouter catalogue with :models openrouter. For a Codex subscription, Panda uses the limit and usage returned with an incomplete response.