From 77e1d9f2b096d239779453f54ba69ce086977204 Mon Sep 17 00:00:00 2001 From: julian-risch <4181769+julian-risch@users.noreply.github.com> Date: Mon, 13 Jul 2026 13:41:21 +0000 Subject: [PATCH] Sync Haystack API reference on Docusaurus --- docs-website/reference/haystack-api/agents_api.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs-website/reference/haystack-api/agents_api.md b/docs-website/reference/haystack-api/agents_api.md index 83a2b61252a..d20138b6ac2 100644 --- a/docs-website/reference/haystack-api/agents_api.md +++ b/docs-website/reference/haystack-api/agents_api.md @@ -219,6 +219,9 @@ Initialize the agent component. - **hooks** (dict\[HookPoint, list\[Hook\]\] | None) – A dictionary mapping a hook point to a list of hooks the Agent runs at that point. Each hook receives the live `State` and influences the run by mutating it in place; hooks for a hook point run in list order. Valid hook points are: +- "before_run": Runs once per run, after the state is initialized and before the first chat-generator + call. Use it to rewrite the initial messages or seed state (e.g. turn the user query into a task + brief) without re-running on every step like "before_llm" does. - "before_llm": Runs before each chat-generator call. - "before_tool": Runs after the model requests tool calls, before any tools run. After these hooks run, 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. Agent running by setting the `continue_run` control flag (`state.set("continue_run", True)`), usually alongside a message telling the model what to do next. "on_exit" hooks run when the Agent stops on an exit condition, but not when it stops because `max_agent_steps` is reached. +- "after_run": Runs once per run, after the step loop has ended and before the Agent builds its return + value — regardless of whether the run stopped on an exit condition or because `max_agent_steps` was + reached (unlike "on_exit"). Mutations to the state (e.g. appending a final message) are reflected in + the returned `messages` / `last_message` and `state_schema` outputs. Setting `continue_run` here has + no effect. **Raises:**