React to events with a mod changedplugins/mods/events
Nearest release: v2.1.336, published an hour after upstream edited the page. Shown because the two are within 24 hours of each other. Nothing here says the release caused the edit.
Upstream edited this page at 3 Dec 2026 17:07 UTC, give or take a minute or two: the time comes from Anthropic’s own sitemap rather than from a commit. This site recorded the change at 3 Dec 2026 17:37 UTC.
Upstream edited
Recorded here
Lines+1added
Lines−1removed
From line
312
where the diff opens
First seen
1 Oct 2026
this site's first read of the page
Recorded edits34to this page, all time
The whole hunk
from line 312, old and new numbered
/
from line 312
312312| :- | :- | :- |
313313| `turn.start` | A turn begins. A subagent's turn fires it with `e.agentId` set, which requires Claude Code v2.1.299 or later. | Observe. `e.turnId` identifies the turn in the other two events. |
314314| `turn.step` | Claude Code is about to send one request to the model. A turn with tool calls has several. `e.agentId` is set for a subagent's request. | Read each request's token usage, send it to a different model with `next({ ...e, model })`, or answer without calling the model |
315| `turn.complete` | The turn ended, including a turn the user interrupted, where `e.isAborted` is `true`. `e.answer` is Claude's final text, `e.durationMs` how long it took, and `e.usage` the turn's token totals. A subagent's turn fires it with `e.agentId` set. | Observe. In the main conversation, return an object with a `text` field, such as `{ text: 'Done in 12 seconds' }`, to show a line under the answer. |
315| `turn.complete` | The turn ended, including a turn the user interrupted, where `e.isAborted` is `true`. `e.reason` is `answer`, `aborted`, `refusal`, or `error`. `e.answer` is Claude's final text, `e.durationMs` how long it took, and `e.usage` the turn's token totals. A subagent's turn fires it with `e.agentId` set. | Observe. In the main conversation, return an object with a `text` field, such as `{ text: 'Done in 12 seconds' }`, to show a line under the answer. |
316316
317317Write a `turn.step` hook as an async generator, because the event streams. `yield* next(e)` forwards the response as it streams and evaluates to the finished result. This hook logs how much of each request the Claude API served from the [prompt cache](https://code.claude.com/docs/en/prompt-caching.md):
318318
No line in this hunk matches that.