You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Console output will show logs from onStart, the tool (if called), and onEnd,
181
184
```
182
-
183
-
In this example:
184
-
185
-
1. The `onStart` hook generates a `requestId` and stores it in `userContext`.
186
-
2. If the LLM decides to use the `custom_context_logger` tool, the tool's `execute` function accesses the `requestId` from `userContext` via the `options.operationContext` provided to it.
187
-
3. The `onEnd` hook retrieves the same `requestId` from the context, demonstrating that the data persisted throughout the operation's lifecycle.
Copy file name to clipboardExpand all lines: website/docs/agents/overview.md
+38-23Lines changed: 38 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -272,41 +272,56 @@ console.log(response.text);
272
272
273
273
**Why?** To observe and potentially intercept or modify the agent's behavior at various lifecycle stages (start, end, tool calls, etc.) for logging, debugging, or custom logic.
274
274
275
-
Hooks are triggered at specific points during the execution of `generate*`/`stream*` methods.
275
+
Hooks are triggered at specific points during the execution of `generate*`/`stream*` methods. Each hook receives a single argument object containing relevant information like the agent instance and operation context.
0 commit comments