mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 06:04:40 +00:00
This commit is contained in:
parent
ff5148e7cc
commit
6da488a5aa
2 changed files with 48 additions and 1 deletions
|
|
@ -237,6 +237,7 @@ user sends prompt ────────────────────
|
|||
├─► (skill/template expansion if not handled) │
|
||||
├─► before_agent_start (can inject message, modify system prompt)
|
||||
├─► agent_start │
|
||||
├─► message_start / message_update / message_end │
|
||||
│ │
|
||||
│ ┌─── turn (repeats while LLM calls tools) ───┐ │
|
||||
│ │ │ │
|
||||
|
|
@ -245,7 +246,9 @@ user sends prompt ────────────────────
|
|||
│ │ │ │
|
||||
│ │ LLM responds, may call tools: │ │
|
||||
│ │ ├─► tool_call (can block) │ │
|
||||
│ │ │ tool executes │ │
|
||||
│ │ ├─► tool_execution_start │ │
|
||||
│ │ ├─► tool_execution_update │ │
|
||||
│ │ ├─► tool_execution_end │ │
|
||||
│ │ └─► tool_result (can modify) │ │
|
||||
│ │ │ │
|
||||
│ └─► turn_end │ │
|
||||
|
|
@ -434,6 +437,46 @@ pi.on("turn_end", async (event, ctx) => {
|
|||
});
|
||||
```
|
||||
|
||||
#### message_start / message_update / message_end
|
||||
|
||||
Fired for message lifecycle updates.
|
||||
|
||||
- `message_start` and `message_end` fire for user, assistant, and toolResult messages.
|
||||
- `message_update` fires for assistant streaming updates.
|
||||
|
||||
```typescript
|
||||
pi.on("message_start", async (event, ctx) => {
|
||||
// event.message
|
||||
});
|
||||
|
||||
pi.on("message_update", async (event, ctx) => {
|
||||
// event.message
|
||||
// event.assistantMessageEvent (token-by-token stream event)
|
||||
});
|
||||
|
||||
pi.on("message_end", async (event, ctx) => {
|
||||
// event.message
|
||||
});
|
||||
```
|
||||
|
||||
#### tool_execution_start / tool_execution_update / tool_execution_end
|
||||
|
||||
Fired for tool execution lifecycle updates.
|
||||
|
||||
```typescript
|
||||
pi.on("tool_execution_start", async (event, ctx) => {
|
||||
// event.toolCallId, event.toolName, event.args
|
||||
});
|
||||
|
||||
pi.on("tool_execution_update", async (event, ctx) => {
|
||||
// event.toolCallId, event.toolName, event.args, event.partialResult
|
||||
});
|
||||
|
||||
pi.on("tool_execution_end", async (event, ctx) => {
|
||||
// event.toolCallId, event.toolName, event.result, event.isError
|
||||
});
|
||||
```
|
||||
|
||||
#### context
|
||||
|
||||
Fired before each LLM call. Modify messages non-destructively. See [session.md](session.md) for message types.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue