Agent Core Concepts: Model, Tool, Instruction — The Three Pillars
Table of Contents
Agent Core Concepts: Model, Tool, Instruction — The Three Pillars
First time encountering ADK Go, the most confusing thing isn’t how to call the API, but “what exactly is an Agent”. This article clarifies Agent’s core concepts—specifically the relationships between Model, Tool, and Instruction.
Agent Essence: A Runtime Wrapper for Large Language Models
The essence of an Agent is giving a Large Language Model (LLM) hands and feet, so it can not only answer questions but also actually get things done.
An LLM itself only knows how to “think”—give it some text, it returns some text. But an Agent knows:
- What tools it can call (Tool)
- How to decide which tool to call based on user input
- How to process results after calling tools
- How to return results to the user
An Agent in ADK Go consists of three core elements: Model, Tool, Instruction.
Model: Agent’s “Brain”
Model is the Agent’s reasoning engine. ADK Go uses Google Gemini series models by default, but can also connect to other models supporting OpenAI compatible APIs.
model, err := gemini.NewModel(ctx, "gemini-flash-latest", &genai.ClientConfig{
APIKey: os.Getenv("GOOGLE_API_KEY"),
})
Model’s Responsibilities:
- Understand user input
- Decide whether to call a Tool
- Generate natural response text
Model Configuration Items:
| Config | Description | Example |
|---|---|---|
| Model name | Which model to use | gemini-flash-latest |
| Temperature | Creativity level (0~1) | 0.7 |
| TopP | Sampling threshold | 0.95 |
| MaxTokens | Max tokens per output | 8192 |
Lower Temperature means more deterministic, conservative output; higher means more creative but possibly more erratic. Setting to ~0.7 during debugging is a good starting point.
Tool: Agent’s “Hands and Feet”
Tool is what an Agent can do. ADK Go has some commonly used tools pre-built, or you can write your own.
ADK Go Pre-built Tools:
| Tool | Description |
|---|---|
geminitool.GoogleSearch | Search tool, Agent can search real-time info |
| MCP Tool | Connect to external services via MCP protocol |
| OpenAPI Tool | Generate tools from OpenAPI specs |
Custom Tool Example: A weather query tool for Agent:
type weatherTool struct{}
func (w weatherTool) Name() string {
return "get_weather"
}
func (w weatherTool) Description() string {
return "Get current weather for a city"
}
func (w weatherTool) InputSchema() string {
return `{"type": "object", "properties": {"city": {"type": "string"}}}`
}
func (w weatherTool) Call(ctx context.Context, input string) (string, error) {
var args struct {
City string `json:"city"`
}
json.Unmarshal([]byte(input), &args)
return fmt.Sprintf("Weather in %s: sunny, 22°C", args.City), nil
}
Register to Agent:
Tools: []tool.Tool{
weatherTool{},
geminitool.GoogleSearch{},
}
When user asks “How’s the weather in Shanghai?”, Agent automatically recognizes it needs to call get_weather, then “speaks” the result to the user.
Instruction: Agent’s “Personality”
Instruction is the system prompt (System Prompt) given to the Model, determining Agent’s role definition, behavioral norms, and response style.
timeAgent, err := llmagent.New(llmagent.Config{
Name: "hello_time_agent",
Model: model,
Description: "Tells the current time in a specified city.",
Instruction: "You are a helpful assistant that tells the current time in a city. "
+ "Be concise and friendly in your responses.",
Tools: []tool.Tool{geminitool.GoogleSearch{}},
})
Instruction Content Suggestions:
- Role Definition: What identity is the Agent? “You are an expert in the xxx field”
- Behavioral Norms: What should the Agent do? “Keep answers concise”, “Always cite data sources”
- Boundary Constraints: What can’t the Agent do? “Don’t fabricate data”, “Explain when beyond capability”
Instruction isn’t better the longer it is. Too long consumes lots of context quota, and Model easily ignores secondary instructions. Best Instruction is precise, concise, and clear.
How the Three Elements Work Together
User Input
↓
Instruction (defines behavioral boundaries)
↓
Model (understands input, decides whether to call Tool)
↓
Tool (executes action)
↓
Model (processes Tool return, generates response)
↓
Output to user
Example:
User asks: “How’s the weather in Shanghai today?”
- Model receives user input, combines with Instruction to understand: user wants to know weather
- Model decides: needs to call weather tool
- Tool is called, returns:
{"city": "Shanghai"}→"Weather in Shanghai: sunny, 22°C" - Model gets tool return result, organizes reply in natural language
- User sees: “Shanghai today is sunny, temperature 22°C”
Example: Minimal Agent Configuration
After understanding three elements, see a minimal Agent configuration:
model, _ := gemini.NewModel(ctx, "gemini-flash-latest", &genai.ClientConfig{
APIKey: os.Getenv("GOOGLE_API_KEY"),
})
agent, _ := llmagent.New(llmagent.Config{
Name: "my-agent", // Agent name
Model: model, // Brain
Instruction: "You are my assistant.", // Personality
Tools: []tool.Tool{}, // Tools (empty here)
})
An Agent without Tools can only “chat”—limited in what it can do. Add Tools, and the Agent gains the ability to “get things done”.
Common Issues
Q: Is longer Instruction better? A: No. Precise, concise Instruction is more effective than lengthy exposition. Model’s context window is limited, too long Instruction crowds out actual conversation space.
Q: How many Tools can one Agent have? A: Theoretically an Agent can have any number of Tools. But the more Tools, the higher the cost for Model to choose which to call. Usually recommend keeping one Agent to 5~10 Tools.
Q: What’s the difference between Instruction and Tool Description? A: Instruction is system-level prompt, determining Agent’s overall behavior; Tool Description is each Tool’s description, telling Model when to call this Tool.
Next Steps
After understanding three elements, run a complete Agent with Hello World Agent to deepen sensory understanding of the whole process.
← Project Structure & .env | Hello World Agent →
Follow “Mengshou Programming” on WeChat for more Go ADK hands-on tutorials, weekly updates on Go / AI programming 实战干货.
