Overview
The rootAgent is equipped with threeFunctionTool implementations from the Google ADK framework. These tools enable the agent to retrieve time information, create visual diagrams, and display source code.
All tools use Zod schemas for parameter validation and type safety.
FunctionTool Structure
Each tool in the ADK follows this structure:Tool 1: getCurrentTime
Overview
Retrieves the current time for a specified city. This is a mock implementation that returns a fixed time.Parameters
The name of the city for which to retrieve the current time.
Complete Implementation
Usage Example
When a user asks: “What time is it in London?” The agent will:- Recognize the time query
- Call
get_current_timewithcity: "London" - Return: “The current time in London is 10:30 AM”
Return Format
Tool 2: createMermaidDiagram
Overview
Generates Mermaid diagrams in markdown format. Supports nine different diagram types for various visualization needs.Parameters
The type of diagram to create. Supported values:
flowchart- Flow charts and process diagramssequence- Sequence diagrams for interactionsclass- Class diagrams for object-oriented designstate- State diagrams for state machineser- Entity-relationship diagramsgantt- Gantt charts for project timelinespie- Pie charts for data visualizationmindmap- Mind maps for brainstormingtimeline- Timeline diagrams
The mermaid diagram definition using Mermaid syntax.
Complete Implementation
Usage Example
When a user asks: “Show me a flowchart of a login process” The agent will:- Recognize the diagram request
- Call
create_mermaid_diagramwith appropriate type and definition - Return a formatted markdown code block with the Mermaid diagram
Return Format
Diagram Types Reference
Flowchart
Flowchart
Process flows and decision trees
Sequence
Sequence
Interactions between components or actors
Class
Class
Object-oriented class structures
Tool 3: viewSourceCode
Overview
Displays source code in a formatted code block. Useful for showing code examples or implementations to users.Parameters
The kind of source code the user wants to see. This serves as both the description and the code content to display.
Complete Implementation
Usage Example
When a user asks: “Show me the agent configuration code” The agent will:- Recognize the source code request
- Call
view_source_codewith the relevant code - Return a formatted code block
Return Format
Creating Custom Tools
Step-by-Step Guide
Best Practices
Clear Naming
Use descriptive snake_case names that clearly indicate the tool’s purpose
Detailed Descriptions
Write clear descriptions to help the LLM understand when to use the tool
Type Safety
Use Zod schemas for all parameters to ensure type validation
Consistent Returns
Always return objects with
status and report fieldsZod Parameter Schemas
Common Zod Types
Complex Example
Tool Execution Flow
Source Location
All tools are defined in:~/workspace/source/app/agents/agent1.ts
Next Steps
Root Agent
Learn about the rootAgent configuration
ADK Documentation
Explore the Google ADK framework