Skip to content

capture before_run modifications and fix session history sync in runners.py#6147

Open
llalitkumarrr wants to merge 4 commits into
google:mainfrom
llalitkumarrr:main
Open

capture before_run modifications and fix session history sync in runners.py#6147
llalitkumarrr wants to merge 4 commits into
google:mainfrom
llalitkumarrr:main

Conversation

@llalitkumarrr

Copy link
Copy Markdown
Collaborator

1. Link to an existing issue (if applicable):

Problem:
ADK 2.0 ignores before_run callback returning a value for workflows. In this case the execution should either stop or use modified message retuned by callback function.

Solution:
Changes introduced:

Captures corrected_user_message from the callback response.
Updates node_input and ic.user_content to pass the mutated message into the Workflow graph engine.
Pops the original un-sanitized user event from ic.session.events to prevent dirty duplicates in the conversation history before appending the modified event.

…n_callback

Fixes a bug in `_run_node_async` where the return value of `before_run_callback` was being swallowed and discarded during workflow execution. 

Changes introduced:
- Captures `corrected_user_message` from the callback response.
- Updates `node_input` and `ic.user_content` to pass the modified message into the Workflow graph engine.
- Pops the original un-sanitized user event from `ic.session.events` to prevent dirty duplicates in the conversation history before appending the modified event.
@rohityan rohityan self-assigned this Jun 17, 2026
@rohityan rohityan added the services [Component] This issue is related to runtime services, e.g. sessions, memory, artifacts, etc label Jun 17, 2026
@wyf7107 wyf7107 self-assigned this Jun 17, 2026
@rohityan

Copy link
Copy Markdown
Collaborator

Hi @llalitkumarrr , can you fix the failing unit test.

@GWeale GWeale added the import label Jun 18, 2026
@llalitkumarrr

Copy link
Copy Markdown
Collaborator Author

Hello @rohityan ,

All unit tests have been fixed and passed successfully.

@GWeale GWeale removed the import label Jun 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

services [Component] This issue is related to runtime services, e.g. sessions, memory, artifacts, etc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ADK 2.0 ignores before_run callback for Workflow

4 participants