Visitar URL original
fix(events): treat an error event without function calls as a final response by Laurianti · Pull Request #1572 · google/adk-java · GitHub
Skip to content

fix(events): treat an error event without function calls as a final response - #1572

Open
Laurianti wants to merge 1 commit into
google:mainfrom
Laurianti:fix-error-event-final-response
Open

Laurianti wants to merge 1 commit into
google:mainfrom
Laurianti:fix-error-event-final-response

Conversation

@Laurianti

@Laurianti Laurianti commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Link to Issue or Description of Change

2. Or, if no issue exists, describe the change:

Ports the adk-python fix google/adk-python@75ae2db to Event.finalResponse().

Problem:

adk-python treats a complete event that carries an error code as a final response unless it contains function calls. In Java, an error event that holds a function response is not a final response, so callers that wait for the final response do not stop on it.

Solution:

Same rule as adk-python: finalResponse() returns true when errorCode() is present, the event is not partial and it has no function calls. Two kinds of error events become final responses: one that holds a function response and one that ends in a code execution result. Events without an error code are unchanged.

Testing Plan

Unit Tests:

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

The four adk-python error-event tests are ported to EventTest: error event with text (final), with a function response (final), with a function call (not final), partial (not final). Also ported test_is_final_response_with_function_response_is_not_final and test_is_final_response_with_trailing_code_result_is_not_final, and added an error event ending with a code execution result (final). Without the fix the error event with a function response fails; without the errorCode().isPresent() check the two ported non-error tests fail. mvn -pl core test: 1890 tests, 0 failures, 0 errors, 24 skipped.

Manual End-to-End (E2E) Tests:

Not needed: the change is limited to Event.finalResponse().

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.

@hemasekhar-p hemasekhar-p self-assigned this Sep 29, 2026
@hemasekhar-p

Copy link
Copy Markdown
Contributor

Hi @Laurianti, Thank you for your contribution and for taking the time to submit this pull request. Our team is currently reviewing your changes and we will reach out if we need any further information. Thank you.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Right now, nothing checks that the error code makes the difference. If you drop errorCode().isPresent() from the new condition, every test in EventTest still passes, because none verify that an error-free function-response event is not final.

Could you port test_is_final_response_with_function_response_is_not_final and test_is_final_response_with_trailing_code_result_is_not_final from adk-python? It would also be great to add a test showing that an error event ending with a code execution result is final.

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.

Fixed in 617dff4: ported test_is_final_response_with_function_response_is_not_final and test_is_final_response_with_trailing_code_result_is_not_final, and added finalResponse_isTrueForErrorEventWithTrailingCodeExecutionResult. Without errorCode().isPresent() the first two now fail.

@dosadczuk dosadczuk added waiting on reporter Waiting for reaction by reporter. Failing that, maintainers will eventually closed it as stale. needs update and removed needs review labels Sep 30, 2026
…esponse

Matches adk-python: a complete event carrying an error code ends the turn
unless the model still asked for tools, even when it holds a function
response.
@Laurianti
Laurianti force-pushed the fix-error-event-final-response branch from 4ca024e to 617dff4 Compare September 30, 2026 11:10

@dosadczuk dosadczuk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The PR description lost its line breaks: it's a single line, so GitHub renders all of it as one heading and the checkboxes don't show. Could you restore the template's line breaks?

Also, "The other cases are unchanged" isn't quite right: an error event ending in a code execution result now becomes final too (your finalResponse_isTrueForErrorEventWithTrailingCodeExecutionResult covers it).

@Laurianti

Copy link
Copy Markdown
Contributor Author

Thanks, both fixed:

  • The description has the template's line breaks again, so the headings and the checkboxes render.
  • The Solution no longer says the other cases are unchanged: it names the two error events that become final responses, one holding a function response and one ending in a code execution result, and says events without an error code are unchanged.

@Laurianti
Laurianti requested a review from dosadczuk October 2, 2026 04:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs update waiting on reporter Waiting for reaction by reporter. Failing that, maintainers will eventually closed it as stale.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants