Skip to content

Remove loopagent dependency from sequential agent#611

Merged
dpasiukevich merged 2 commits intogoogle:mainfrom
baptmont:sequential_dependency
Mar 4, 2026
Merged

Remove loopagent dependency from sequential agent#611
dpasiukevich merged 2 commits intogoogle:mainfrom
baptmont:sequential_dependency

Conversation

@baptmont
Copy link
Contributor

@baptmont baptmont commented Mar 3, 2026

No description provided.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, 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 refactors the SequentialAgent to eliminate its reliance on the LoopAgent. Previously, the SequentialAgent was built upon the LoopAgent with a single iteration constraint. The change decouples this relationship by implementing a custom sequential execution flow directly within the SequentialAgent, enhancing its autonomy and clarity of purpose.

Highlights

  • Dependency Removal: Removed the direct dependency on the loopagent package from the sequentialagent by refactoring its internal implementation.
  • Custom Sequential Execution: Introduced a new sequentialAgent struct with a dedicated Run method that explicitly handles the sequential execution of sub-agents.
  • Agent Initialization: Modified the New function to directly create a base agent.Agent and inject the custom sequential execution logic, replacing the previous loopagent.New call.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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 refactors the sequentialagent to remove its dependency on loopagent, simplifying the implementation and correctly running sub-agents in sequence. However, the new Run implementation introduces a high-severity security vulnerability by failing to stop the execution sequence when a sub-agent encounters an error, requests an escalation, or initiates a transfer. This critical control flow issue could lead to security bypasses, such as authorization checks. Additionally, an incorrect error message due to a copy-paste needs to be corrected. Addressing these points is crucial for robustness and security.

I am having trouble creating individual review comments. Click here to see my feedback.

agent/workflowagents/sequentialagent/agent.go (67-78)

security-high high

The Run implementation of SequentialAgent has a critical control flow vulnerability. It iterates through all sub-agents even if a previous sub-agent yielded an error, requested an escalation, or initiated a transfer. This can lead to inconsistent state and bypass of security checks, such as authorization, if the sequence of agents depends on the success or specific control flow of previous steps. The current implementation continues processing subsequent sub-agents despite an error, which is inconsistent with the TODO comment suggesting the iterator should be closed on error.

func (a *sequentialAgent) Run(ctx agent.InvocationContext) iter.Seq2[*session.Event, error] { return func(yield func(*session.Event, error) bool) { for _, subAgent := range ctx.Agent().SubAgents() { if ctx.Ended() { return	} stopSequence := false for event, err := range subAgent.Run(ctx) { if !yield(event, err) { return	} if err != nil { stopSequence = true break	} if event != nil && (event.Actions.Escalate || event.Actions.TransferToAgent != "") { stopSequence = true break	}	} if stopSequence || ctx.Ended() { return	}	}	} }

agent/workflowagents/sequentialagent/agent.go (35)

medium

The error message refers to LoopAgent, but it should be SequentialAgent. This appears to be a copy-paste from another agent's implementation.

return nil, fmt.Errorf("SequentialAgent doesn't allow custom Run implementations") 
@dpasiukevich dpasiukevich merged commit 5763064 into google:main Mar 4, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants