|
| 1 | +--- |
| 2 | +title: "Annotate Last" |
| 3 | +description: "The /plannotator-last slash command for annotating the agent's most recent message." |
| 4 | +sidebar: |
| 5 | + order: 13 |
| 6 | +section: "Commands" |
| 7 | +--- |
| 8 | + |
| 9 | +The `/plannotator-last` command opens the agent's most recent response in the annotation UI, letting you highlight text, add comments, and send structured feedback back. |
| 10 | + |
| 11 | +## Usage |
| 12 | + |
| 13 | +### Claude Code |
| 14 | + |
| 15 | +``` |
| 16 | +/plannotator-last |
| 17 | +``` |
| 18 | + |
| 19 | +### OpenCode |
| 20 | + |
| 21 | +``` |
| 22 | +/plannotator-last |
| 23 | +``` |
| 24 | + |
| 25 | +### Pi |
| 26 | + |
| 27 | +``` |
| 28 | +/plannotator-last |
| 29 | +``` |
| 30 | + |
| 31 | +### Codex |
| 32 | + |
| 33 | +``` |
| 34 | +!plannotator last |
| 35 | +``` |
| 36 | + |
| 37 | +## How it works |
| 38 | + |
| 39 | +``` |
| 40 | +User runs /plannotator-last |
| 41 | + ↓ |
| 42 | +Last assistant message extracted from session |
| 43 | + ↓ |
| 44 | +Annotate server starts (random port) |
| 45 | + ↓ |
| 46 | +Browser opens, loads annotation UI |
| 47 | + ↓ |
| 48 | +/api/plan returns { plan: message, mode: "annotate-last" } |
| 49 | + ↓ |
| 50 | +User annotates → Send Annotations |
| 51 | + ↓ |
| 52 | +Feedback sent to agent |
| 53 | +``` |
| 54 | + |
| 55 | +## Session log parsing |
| 56 | + |
| 57 | +Each harness reads the last assistant message differently: |
| 58 | + |
| 59 | +| Harness | Source | Method | |
| 60 | +|---------|--------|--------| |
| 61 | +| **Claude Code** | `~/.claude/projects/{slug}/*.jsonl` | Parses JSONL session logs, finds last assistant text blocks | |
| 62 | +| **OpenCode** | SDK | `client.session.messages()` API | |
| 63 | +| **Pi** | SDK | `ctx.sessionManager.getEntries()` API | |
| 64 | +| **Codex** | `~/.codex/sessions/` rollout files | Parses JSONL by `CODEX_THREAD_ID` env var | |
| 65 | + |
| 66 | +For Claude Code, the parser handles streamed chunks (multiple JSONL lines sharing the same `message.id`), filters out system-generated user messages, and skips noise entries. If the most recent session log has no assistant messages, it tries earlier logs sorted by modification time. |
| 67 | + |
| 68 | +## Annotate-last mode differences |
| 69 | + |
| 70 | +The annotation UI in `annotate-last` mode works the same as `/plannotator-annotate`, with minor copy changes: |
| 71 | + |
| 72 | +- Copy button shows "Copy message" instead of "Copy plan" |
| 73 | +- Completion screen says "annotations on the message" |
| 74 | +- Feedback export is titled "Message Feedback" instead of "Plan Feedback" |
| 75 | + |
| 76 | +## Server API |
| 77 | + |
| 78 | +The annotate-last mode reuses the same annotate server endpoints. See the [annotate docs](/docs/commands/annotate/#server-api). |
| 79 | + |
| 80 | +## Environment variables |
| 81 | + |
| 82 | +Same as plan review. See the [environment variables reference](/docs/reference/environment-variables/). |
0 commit comments