Skip to content

Instantly share code, notes, and snippets.

@glaforge
Created July 28, 2025 14:49
Show Gist options
  • Save glaforge/da0c39d4e22e8e663ec2a31125f23021 to your computer and use it in GitHub Desktop.
Save glaforge/da0c39d4e22e8e663ec2a31125f23021 to your computer and use it in GitHub Desktop.
SequentialFlow.java class illustrating ADK AI agent sequential flows in Java
var companyProfiler = LlmAgent.builder()
.name("company-profiler")
.description(
"Provides a general overview of a company.")
.instruction("""
Your role is to provide a brief overview of the
given company.
Include its mission, headquarters, and current CEO.
Use the Google Search Tool to find this information.
""")
.model("gemini-2.0-flash")
.tools(new GoogleSearchTool())
.outputKey("profile")
.build();
var newsFinder = LlmAgent.builder()
.name("news-finder")
.description(
"Finds the latest news about a company.")
.instruction("""
Your role is to find the top 3-4 recent news headlines
for the given company.
Use the Google Search Tool.
Present the results as a simple bulleted list.
""")
.model("gemini-2.0-flash")
.tools(new GoogleSearchTool())
.outputKey("news")
.build();
var financialAnalyst = LlmAgent.builder()
.name("financial-analyst")
.description(
"Analyzes the financial performance of a company.")
.instruction("""
Your role is to provide a snapshot of the given company's
recent financial performance.
Focus on stock trends or recent earnings reports.
Use the Google Search Tool.
""")
.model("gemini-2.0-flash")
.tools(new GoogleSearchTool())
.outputKey("financials")
.build();
var marketResearcher = ParallelAgent.builder()
.name("market-researcher")
.description(
"Performs comprehensive market research on a company.")
.subAgents(
companyProfiler,
newsFinder,
financialAnalyst
)
.build();
var reportCompiler = LlmAgent.builder()
.name("report-compiler")
.description(
"Compiles a final market research report.")
.instruction("""
Your role is to synthesize the provided information
into a coherent market research report.
Combine the company profile, latest news, and
financial analysis into a single, well-formatted report.
## Company Profile
{profile}
## Latest News
{news}
## Financial Snapshot
{financials}
""")
.model("gemini-2.0-flash")
.build();
return SequentialAgent.builder()
.name("company-detective")
.description(
"Collects various market information about a company.")
.subAgents(
marketResearcher,
reportCompiler
).build();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment