Skip to content

Commit 6da488a

Browse files
committed
docs(coding-agent): add #1375 changelog entry and extension event docs fixes #1375
1 parent ff5148e commit 6da488a

2 files changed

Lines changed: 48 additions & 1 deletion

File tree

packages/coding-agent/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66

77
- `ContextUsage.tokens` and `ContextUsage.percent` are now `number | null`. After compaction, context token count is unknown until the next LLM response, so these fields return `null`. Extensions that read `ContextUsage` must handle the `null` case. Removed `usageTokens`, `trailingTokens`, and `lastUsageIndex` fields from `ContextUsage` (implementation details that should not have been public) ([#1382](https://github.com/badlogic/pi-mono/pull/1382) by [@ferologics](https://github.com/ferologics))
88

9+
### Added
10+
11+
- Added extension event forwarding for message and tool execution lifecycles (`message_start`, `message_update`, `message_end`, `tool_execution_start`, `tool_execution_update`, `tool_execution_end`) ([#1375](https://github.com/badlogic/pi-mono/pull/1375) by [@sumeet](https://github.com/sumeet))
12+
913
### Fixed
1014

1115
- Fixed context usage percentage in footer showing stale pre-compaction values. After compaction the footer now shows `?/200k` until the next LLM response provides accurate usage ([#1382](https://github.com/badlogic/pi-mono/pull/1382) by [@ferologics](https://github.com/ferologics))

packages/coding-agent/docs/extensions.md

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ user sends prompt ────────────────────
237237
├─► (skill/template expansion if not handled) │
238238
├─► before_agent_start (can inject message, modify system prompt)
239239
├─► agent_start │
240+
├─► message_start / message_update / message_end │
240241
│ │
241242
│ ┌─── turn (repeats while LLM calls tools) ───┐ │
242243
│ │ │ │
@@ -245,7 +246,9 @@ user sends prompt ────────────────────
245246
│ │ │ │
246247
│ │ LLM responds, may call tools: │ │
247248
│ │ ├─► tool_call (can block) │ │
248-
│ │ │ tool executes │ │
249+
│ │ ├─► tool_execution_start │ │
250+
│ │ ├─► tool_execution_update │ │
251+
│ │ ├─► tool_execution_end │ │
249252
│ │ └─► tool_result (can modify) │ │
250253
│ │ │ │
251254
│ └─► turn_end │ │
@@ -434,6 +437,46 @@ pi.on("turn_end", async (event, ctx) => {
434437
});
435438
```
436439

440+
#### message_start / message_update / message_end
441+
442+
Fired for message lifecycle updates.
443+
444+
- `message_start` and `message_end` fire for user, assistant, and toolResult messages.
445+
- `message_update` fires for assistant streaming updates.
446+
447+
```typescript
448+
pi.on("message_start", async (event, ctx) => {
449+
// event.message
450+
});
451+
452+
pi.on("message_update", async (event, ctx) => {
453+
// event.message
454+
// event.assistantMessageEvent (token-by-token stream event)
455+
});
456+
457+
pi.on("message_end", async (event, ctx) => {
458+
// event.message
459+
});
460+
```
461+
462+
#### tool_execution_start / tool_execution_update / tool_execution_end
463+
464+
Fired for tool execution lifecycle updates.
465+
466+
```typescript
467+
pi.on("tool_execution_start", async (event, ctx) => {
468+
// event.toolCallId, event.toolName, event.args
469+
});
470+
471+
pi.on("tool_execution_update", async (event, ctx) => {
472+
// event.toolCallId, event.toolName, event.args, event.partialResult
473+
});
474+
475+
pi.on("tool_execution_end", async (event, ctx) => {
476+
// event.toolCallId, event.toolName, event.result, event.isError
477+
});
478+
```
479+
437480
#### context
438481

439482
Fired before each LLM call. Modify messages non-destructively. See [session.md](session.md) for message types.

0 commit comments

Comments
 (0)