Skip to content

Commit 08456dc

Browse files
author
yana-gi
committed
docs(plugins): correct before_run_callback flow control behavior
The "Runner start callbacks" section described `before_run_callback` as returning a `types.Content` to "replace the user's original message". That is actually the behavior of `on_user_message_callback`; the text (including the "Purpose" line) was duplicated from that section. In the implementation, returning a `Content` from `before_run_callback` halts the run: the Runner yields it as an early-exit event and skips all subsequent processing instead of invoking the agent. See `Runner._exec_with_plugin` in `src/google/adk/runners.py`: early_exit_result = await plugin_manager.run_before_run_callback(...) if isinstance(early_exit_result, types.Content): early_exit_event = Event(..., content=early_exit_result) ... yield early_exit_event # early exit, agent never runs else: # normal execution This also matches the BasePlugin docstring: "Returning a value to halt execution of the runner and ends the runner with that event." Fix the "When It Runs", "Purpose", and "Flow Control" bullets accordingly.
1 parent 9db36de commit 08456dc

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

docs/plugins/index.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -796,12 +796,12 @@ object takes the potentially modified user message and prepares for execution.
796796
The `before_run_callback` fires here, allowing for global setup before any agent
797797
logic begins.
798798

799-
- **When It Runs:** Immediately after `runner.run()` is called, before
800-
any other processing.
801-
- **Purpose:** The first opportunity to inspect or modify the user's raw
802-
input.
803-
- **Flow Control:** Return a `types.Content` object to **replace** the
804-
user's original message.
799+
- **When It Runs:** After the `on_user_message_callback`, when the `Runner`
800+
prepares for execution and before any agent logic begins.
801+
- **Purpose:** Global setup or initialization before the invocation runs.
802+
- **Flow Control:** Return a `types.Content` object to **halt execution**:
803+
the `Runner` exits early and ends the run with that content as the result.
804+
Return `None` to proceed normally.
805805

806806
The following code example shows the basic syntax of this callback:
807807

0 commit comments

Comments
 (0)