Skip to content

fix: ignore usage-only responses (except for BIDI mode)#1254

Open
r4inee wants to merge 1 commit into
google:mainfrom
r4inee:ssu/fix-code-exec-usage-only-event
Open

fix: ignore usage-only responses (except for BIDI mode)#1254
r4inee wants to merge 1 commit into
google:mainfrom
r4inee:ssu/fix-code-exec-usage-only-event

Conversation

@r4inee

@r4inee r4inee commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Link to Issue or Description of Change

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

Problem:
In ADK Java code execution flows, if the model response that contains executable code also has usageMetadata, ADK emits an extra contentless usage-only event after the codeExecutionResult event. That extra event is considered final=true, so BaseLlmFlow stops the loop and does not call the LLM again with the code execution result.

Solution:
Skipping metadata only events unless its in BIDI mode - aligns with adk-python behaviour.

Testing Plan

  • Added unit test to ensure 2nd inference call
  • Added unit to ensure it doesn't affect BIDI mode

Unit Tests:

  • I have added or updated unit tests for my change.
  • All unit tests pass locally.

Please include a summary of passed java test results.

Manual End-to-End (E2E) Tests:

Testing using example mentioned in #1245

Checklist

  • I have read the CONTRIBUTING.md document.
  • My pull request contains a single commit.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • I have manually tested my changes end-to-end.
  • Any dependent changes have been merged and published in downstream modules.

&& !updatedResponse.interrupted().orElse(false)
&& !updatedResponse.turnComplete().orElse(false)
&& updatedResponse.usageMetadata().isEmpty()
&& (context.runConfig().streamingMode() != StreamingMode.BIDI

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adk-python seems to fork the logic in LIVE/BIDI mode - mainly kept in consistent with the logic below for now to avoid a larger change.

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.

bug: Code execution flow emits contentless usage-only final event, preventing LLM loop from resuming

1 participant