Skip to content

Conversation

@binbandit
Copy link
Contributor

This PR fixes issue a2aproject/a2a-samples#38 where the ADK agent was attempting to index a generator object directly, which is not supported in Python.

Problem

In the invoke method of the ReimbursementAgent class, the code was trying to access events[-1] where events is a generator returned by self._runner.run(). Generators don't support indexing, which would cause a TypeError.

Solution

The fix converts the generator to a list before attempting to index it:

events = list(self._runner.run(
    user_id=self._user_id, session_id=session.id, new_message=content
))

@binbandit
Copy link
Contributor Author

bump

1 similar comment
@binbandit
Copy link
Contributor Author

bump

@binbandit
Copy link
Contributor Author

@kthota-g Could I please get a review?

@pstephengoogle
Copy link
Contributor

I believe this is already fixed by an already merged PR. Please confirm

@mindpower mindpower self-assigned this Apr 29, 2025
@mindpower
Copy link

Close this one since it's already fixed by a merged PR.

@mindpower mindpower closed this Apr 29, 2025
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.

3 participants