Skip to content

Conversation

@sheing-google
Copy link

Addressing issue: #423

This commit fixes a nil pointer dereference in the loopagent that occurred when an LLM called a tool that was not registered with the current agent. The agent now gracefully handles the error and continues execution instead of crashing.

Test: Passed.

google-labs-jules bot and others added 4 commits December 17, 2025 19:29
Adds the 'gen_ai.conversation.id' attribute to OpenTelemetry spans for LLM calls. This helps link conversation messages together in AI Evals platforms by using the existing session ID.

This change is additive and does not remove the existing 'gcp.vertex.agent.session_id' attribute.
…n-id-8998566208331097961

Include gen_ai.conversation.id in OTEL spans
When an LLM calls a tool that is not registered with the current agent,
the ADK crashes with a nil pointer dereference instead of gracefully
handling the error. The `loopagent` accesses `event.Actions.Escalate`
without checking if `event` is nil after an error is returned.

This commit fixes the nil pointer dereference in the loopagent by adding
a check to ensure `event` is not `nil` before accessing its properties.
A new test case has also been added to reproduce the panic and verify
the fix.
Removed genAiConversationID from telemetry attributes.
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @sheing-google, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical stability issue in the loopagent where it would crash due to a nil pointer dereference when an LLM attempted to use an unregistered tool. The changes implement robust error handling within the agent's execution loop, allowing it to recover gracefully from such scenarios and continue operation without unexpected termination. This significantly enhances the reliability of the agent's workflow.

Highlights

  • Graceful Error Handling: The loopagent now gracefully handles errors that occur when an LLM calls an unregistered tool or when a sub-agent encounters an error, preventing nil pointer dereferences and crashes.
  • Improved Loop Control: The agent's main Run loop has been refactored to properly break and return when an error is detected or an escalation event occurs, ensuring cleaner exit conditions.
  • Enhanced Test Coverage: New test fields and a dedicated test case have been added to specifically verify that the loopagent does not panic when a sub-agent returns an error, improving the robustness of the test suite.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request addresses a nil pointer dereference in the loopagent by adding proper error and nil-event handling. The changes in agent.go correctly prevent the crash when a sub-agent returns an error. The accompanying test in agent_test.go is well-written, introducing an errorAgent to simulate the failure case and verifying that the loopagent handles it gracefully without panicking.

My review includes one suggestion to slightly refactor the new conditional logic for better conciseness. Overall, this is a good fix that improves the robustness of the agent.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
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.

1 participant