Repository navigation
Conversation
When a plugin's beforeRunCallback returned content, the Runner stored and yielded the early-exit event directly, so no plugin's onEventCallback saw the blocked reply and a plugin could not log, redact or tag it. Send the early-exit event through processAndAppendEvent in runAsync and runLive, as runAsync already does for the agent's events and as adk-python does since google/adk-python@63e918a.
Check the abort signal after processing a before-run live reply, before yielding it. This matches the async early-exit path and keeps replies that were already stored. Add a regression that cancels inside onEventCallback and checks that no reply is yielded or model connection opened while session history remains.
Contributor
|
Hi @nniiovoo, thank you for raising the PR to fix the issue. We have reviewed the code changes and it does resolve the issue. I will escalate the PR to the team to review, thank you for your patience and understanding. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Please ensure you have read the contribution guide before creating a pull request.
Link to Issue or Description of Change
Closes #1147
Problem:
When a plugin's
beforeRunCallbackreturns content, the Runner stores and yields the early-exit event directly. No plugin'sonEventCallbacksees it, so a plugin can't log, redact or tag the blocked reply.Solution:
Send the early-exit event through
processAndAppendEventinrunAsyncandrunLive, asrunAsyncalready does for the agent's events. The same before_run callback gap was fixed in adk-python by 63e918a (google/adk-python#7007), first released in v2.10.0.A blocked reply now goes through
onEventCallbackbefore persistence and streaming.runAsynckeeps its abort check after processing the event.runLivegets the same check, so an abort inside the callback prevents yielding the reply. The check comes after the helper's persistence step and does not roll back replies already persisted. This does not changeafterRunCallbackhandling.Testing Plan
Unit Tests:
Three regression tests:
runAsyncincore/test/runner/runner_test.ts, using the existingMockPlugin, and one forrunLiveincore/test/runner/run_live_test.ts. Both check that rewritten text is yielded and stored under the same event id, and that the yielded event's author ismodel. The live test also checks the incoming blocked text and that no model connection opens.onEventCallback. It checks that nothing is yielded, the blocked reply remains stored, and no model connection opens.All three regressions fail with upstream's
runner.tsand pass with this change. The cancellation test also fails against the initial fix, before adding the abort check.npx vitest run --project unit:core --project unit:dev --maxWorkers=4: 343 files passed, 1 skipped; 6104 tests passed, 2 skipped.npm run ts:check,ts:check:samples,lint,format:check,docs:checkandbuildpass.bash scripts/check_license.shandnpx secretlint '**/*'pass.Manual End-to-End (E2E) Tests:
The issue's stub-model script needs no credentials. The recorded results for the blocked run are:
@google/adk2.3.0 from npm):onEventCallbackis never called; the only line isyielded: Blocked.onEventCallback saw: Blocked., thenyielded: Blocked.The script was rerun on the revised working tree. Integration and e2e test projects and a live model are not covered by this script.
Checklist