Skip to content

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

Closed
llalitkumarrr wants to merge 5 commits into
google:mainfrom
llalitkumarrr:main
Closed

capture before_run modifications and fix session history sync in runners.py#6145
llalitkumarrr wants to merge 5 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.

Updated links in documentation section.
…_run_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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ADK 2.0 ignores before_run callback for Workflow

1 participant