Skip to content

Commit af76cc5

Browse files
docs: sync Haystack API reference on Docusaurus (#11988)
Co-authored-by: julian-risch <4181769+julian-risch@users.noreply.github.com>
1 parent 2082333 commit af76cc5

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

docs-website/reference/haystack-api/agents_api.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,9 @@ Initialize the agent component.
219219
- **hooks** (<code>dict\[HookPoint, list\[Hook\]\] | None</code>) – A dictionary mapping a hook point to a list of hooks the Agent runs at that point. Each hook
220220
receives the live `State` and influences the run by mutating it in place; hooks for a hook point run in
221221
list order. Valid hook points are:
222+
- "before_run": Runs once per run, after the state is initialized and before the first chat-generator
223+
call. Use it to rewrite the initial messages or seed state (e.g. turn the user query into a task
224+
brief) without re-running on every step like "before_llm" does.
222225
- "before_llm": Runs before each chat-generator call.
223226
- "before_tool": Runs after the model requests tool calls, before any tools run. After these hooks run,
224227
the Agent re-reads the current last message from `state.data["messages"]`. If that message contains tool
@@ -232,6 +235,11 @@ Initialize the agent component.
232235
Agent running by setting the `continue_run` control flag (`state.set("continue_run", True)`), usually
233236
alongside a message telling the model what to do next. "on_exit" hooks run when the Agent stops on an
234237
exit condition, but not when it stops because `max_agent_steps` is reached.
238+
- "after_run": Runs once per run, after the step loop has ended and before the Agent builds its return
239+
value — regardless of whether the run stopped on an exit condition or because `max_agent_steps` was
240+
reached (unlike "on_exit"). Mutations to the state (e.g. appending a final message) are reflected in
241+
the returned `messages` / `last_message` and `state_schema` outputs. Setting `continue_run` here has
242+
no effect.
235243

236244
**Raises:**
237245

0 commit comments

Comments
 (0)