Skip to main content
Polpo records everything — chat history, agent transcripts, event logs, and per-run activity. This data powers the TUI dashboard, the web UI, and post-mortem analysis.

Chat Sessions

When you interact with Polpo via the TUI, the OpenAI-compatible endpoint (POST /v1/chat/completions), or the REST API, your messages are persisted in chat sessions. This means you can close the terminal, reopen it, and your conversation history is still there.

How It Works

  1. When you send your first message, Polpo creates a new session
  2. The session title is set to the first 60 characters of your first message
  3. Every message (yours and Polpo’s responses) is saved with a timestamp
  4. If you reopen the TUI within 30 minutes, the previous session is automatically resumed
  5. After 30 minutes of inactivity, a new session starts

Session Data

Each session stores:
FieldDescription
idUnique session ID
titleFirst 60 chars of the first message
createdAtWhen the session started
updatedAtLast message timestamp
messageCountTotal messages in the session

TUI Commands

CommandDescription
/sessionsBrowse past sessions, view messages, delete sessions

REST API

MethodPathDescription
POST/v1/chat/completionsTalk to Polpo (OpenAI-compatible, primary endpoint)
GET/chat/sessionsList all sessions
GET/chat/sessions/:id/messagesGet messages for a session
PATCH/chat/sessions/:idRename a session ({ title: string })
DELETE/chat/sessions/:idDelete a session
The TUI auto-resumes the latest session if it’s less than 30 minutes old. Otherwise, it creates a new one.

Session Events

EventWhen
session:createdNew chat session started
message:addedMessage saved to a session

Agent Transcripts

When Polpo spawns an agent, it creates a session transcript — a JSONL file recording every message, tool call, and result in the agent’s conversation.

Session Reader

Polpo can read agent transcripts to extract structured summaries:
FieldDescription
sessionIdAgent session ID
transcriptPathPath to the JSONL file
messageCountTotal messages in the transcript
toolCallsList of tool names the agent called
filesCreatedFiles the agent created
filesEditedFiles the agent edited
lastMessageLast assistant message (truncated to 300 chars)
todosTODO/FIXME items found in agent output
errorsErrors encountered during execution

Connecting Tasks to Transcripts

Each AgentHandle can carry a sessionId. When a task is running, you can use the /inspect TUI command or the REST API to access the agent’s transcript in real-time.
Agent transcripts are recorded automatically for all agents. Full JSONL logs are written to .polpo/logs/.

Pruning

Sessions accumulate over time. The SessionStore interface includes a prune(keepSessions) method that deletes all but the N most recent sessions. This can be called programmatically or through the TUI session manager.

Event Log

Every event Polpo emits is captured in a persistent LogStore. Each time Polpo starts, it creates a new logging session.

Log Entries

Each log entry contains:
FieldTypeDescription
tsstringISO timestamp
eventstringEvent name (e.g. task:created, agent:spawned)
dataobjectFull event payload

Log Sessions

Events are grouped by session (one per Polpo start):
FieldTypeDescription
sessionIdstringUnique session ID
startedAtstringISO timestamp
entriesnumberTotal log entries in this session

Storage

  • File-based (default): JSONL files in .polpo/logs/
  • SQLite: Alternative via "storage": "sqlite" in settings

Viewing Logs

WhereHow
TUI/logs command, or the Logs tab
REST APIGET /logs (list sessions), GET /logs/:sessionId (entries)
React SDKuseLogs() hook
High-frequency events like orchestrator:tick are excluded from log persistence to avoid noise.

Agent Activity Tracking

While an agent is working on a task, Polpo tracks its activity in real-time. This data feeds the live dashboard, stale detection, and health checks.

Activity Fields

FieldTypeDescription
lastToolstringName of the last tool called (e.g. Write, Bash)
lastFilestringLast file path touched
filesCreatedstring[]Files created during this task
filesEditedstring[]Files edited during this task
toolCallsnumberTotal tool invocations
totalTokensnumberCumulative LLM token usage
lastUpdatestringISO timestamp of last activity
summarystringLatest output snippet
sessionIdstringAgent session ID (for transcript access)

How Activity Flows

Agent activity data flow: agent in runner → RunStore → orchestrator → agent:activity event → TUI / Web UI
  1. The runner polls the engine for activity every 1500ms
  2. Changes are written to the RunStore (so Polpo can read them)
  3. Polpo reads activity on each tick (every 5s) and emits agent:activity events
  4. The TUI and Web UI consume these events for live updates

Stale Detection

If lastUpdate hasn’t changed for longer than staleThreshold (default: 5 minutes), Polpo emits an agent:stale event and may kill the agent.

Per-Run Activity Logs

Every runner writes a detailed JSONL activity log to .polpo/logs/run-<runId>.jsonl. This is a more granular record than Polpo’s event log — it captures individual tool calls, transcript messages, and activity snapshots.

File Format

Each line is a JSON object. The first line is a header:
{"_run": true, "runId": "abc123", "taskId": "task-1", "agentName": "backend-dev", "startedAt": "2025-02-15T14:00:00Z", "pid": 12345}
Subsequent lines are events:
{"ts": "2025-02-15T14:00:05Z", "event": "activity", "data": {"toolCalls": 3, "filesCreated": ["src/db.ts"], "lastUpdate": "..."}}
{"ts": "2025-02-15T14:00:06Z", "type": "assistant", "message": {"role": "assistant", "content": [...]}}

Entry Types

TypeDescription
_run (header)Run metadata: runId, taskId, agentName, startedAt, pid
activityActivity snapshot (deduplicated — only written when data changes)
Transcript entriesRaw engine messages (assistant text, tool_use, tool_result)
Custom eventsLifecycle events logged via logEvent()

Viewing Run Logs

WhereHow
REST APIGET /logs/:sessionId or task activity endpoint
React SDKuseTaskActivity(taskId) hook
Files.polpo/logs/run-<runId>.jsonl
Per-run logs are invaluable for debugging why an agent failed or made unexpected decisions. They capture the full agent conversation including every tool call input and output.