or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

advanced.mdagents.mdauthentication.mdcode-execution.mdgoogle-cloud.mdindex.mdmemory-sessions.mdmodels.mdrunners.mdtools.md

agents.mddocs/

0

# Agent Framework

1

2

Core agent classes and configuration for building single agents and multi-agent systems, supporting various execution patterns and orchestration strategies.

3

4

## Capabilities

5

6

### Base Agent Classes

7

8

Abstract base classes and core agent implementations that form the foundation of the ADK agent system.

9

10

```python { .api }

11

class BaseAgent:

12

"""Abstract base class for all agents."""

13

14

def __init__(self, name: str, description: str = None, **kwargs):

15

"""

16

Initialize a base agent.

17

18

Args:

19

name (str): Agent name

20

description (str, optional): Agent description

21

**kwargs: Additional configuration parameters

22

"""

23

pass

24

25

def run(self, input_text: str, context: InvocationContext = None) -> str:

26

"""

27

Execute the agent with given input.

28

29

Args:

30

input_text (str): Input text for the agent

31

context (InvocationContext, optional): Execution context

32

33

Returns:

34

str: Agent response

35

"""

36

pass

37

38

class LlmAgent(BaseAgent):

39

"""LLM-based agent implementation."""

40

41

def __init__(

42

self,

43

name: str,

44

model: str,

45

instruction: str = None,

46

description: str = None,

47

tools: list = None,

48

sub_agents: list = None,

49

**kwargs

50

):

51

"""

52

Initialize an LLM agent.

53

54

Args:

55

name (str): Agent name

56

model (str): LLM model identifier (e.g., "gemini-2.0-flash")

57

instruction (str, optional): System instruction for the agent

58

description (str, optional): Agent description

59

tools (list, optional): List of tools available to the agent

60

sub_agents (list, optional): List of sub-agents for multi-agent systems

61

**kwargs: Additional configuration parameters

62

"""

63

pass

64

65

# Alias for LlmAgent

66

Agent = LlmAgent

67

```

68

69

### Specialized Agent Types

70

71

Agents designed for specific execution patterns and workflows.

72

73

```python { .api }

74

class LoopAgent(BaseAgent):

75

"""Agent that executes in a loop."""

76

77

def __init__(

78

self,

79

name: str,

80

agent: BaseAgent,

81

max_iterations: int = 10,

82

**kwargs

83

):

84

"""

85

Initialize a loop agent.

86

87

Args:

88

name (str): Agent name

89

agent (BaseAgent): The agent to execute in a loop

90

max_iterations (int): Maximum number of loop iterations

91

**kwargs: Additional configuration parameters

92

"""

93

pass

94

95

class ParallelAgent(BaseAgent):

96

"""Agent for parallel task execution."""

97

98

def __init__(

99

self,

100

name: str,

101

agents: list,

102

**kwargs

103

):

104

"""

105

Initialize a parallel agent.

106

107

Args:

108

name (str): Agent name

109

agents (list): List of agents to execute in parallel

110

**kwargs: Additional configuration parameters

111

"""

112

pass

113

114

class SequentialAgent(BaseAgent):

115

"""Agent for sequential task execution."""

116

117

def __init__(

118

self,

119

name: str,

120

agents: list,

121

**kwargs

122

):

123

"""

124

Initialize a sequential agent.

125

126

Args:

127

name (str): Agent name

128

agents (list): List of agents to execute sequentially

129

**kwargs: Additional configuration parameters

130

"""

131

pass

132

```

133

134

### Agent Configuration and Context

135

136

Configuration and context classes for agent execution and invocation.

137

138

```python { .api }

139

class InvocationContext:

140

"""Context passed during agent invocation."""

141

142

def __init__(

143

self,

144

session_id: str = None,

145

user_id: str = None,

146

metadata: dict = None,

147

**kwargs

148

):

149

"""

150

Initialize invocation context.

151

152

Args:

153

session_id (str, optional): Session identifier

154

user_id (str, optional): User identifier

155

metadata (dict, optional): Additional context metadata

156

**kwargs: Additional context parameters

157

"""

158

pass

159

160

class RunConfig:

161

"""Configuration for agent execution."""

162

163

def __init__(

164

self,

165

max_iterations: int = None,

166

timeout: float = None,

167

temperature: float = None,

168

**kwargs

169

):

170

"""

171

Initialize run configuration.

172

173

Args:

174

max_iterations (int, optional): Maximum execution iterations

175

timeout (float, optional): Execution timeout in seconds

176

temperature (float, optional): LLM temperature setting

177

**kwargs: Additional configuration parameters

178

"""

179

pass

180

```

181

182

### Live Request Handling

183

184

Classes for handling streaming and live agent interactions.

185

186

```python { .api }

187

class LiveRequest:

188

"""Live request object for streaming."""

189

190

def __init__(self, request_data: dict, **kwargs):

191

"""

192

Initialize a live request.

193

194

Args:

195

request_data (dict): Request data

196

**kwargs: Additional request parameters

197

"""

198

pass

199

200

class LiveRequestQueue:

201

"""Queue for managing live requests."""

202

203

def __init__(self, max_size: int = None, **kwargs):

204

"""

205

Initialize a live request queue.

206

207

Args:

208

max_size (int, optional): Maximum queue size

209

**kwargs: Additional queue parameters

210

"""

211

pass

212

213

def put(self, request: LiveRequest):

214

"""

215

Add a request to the queue.

216

217

Args:

218

request (LiveRequest): Request to add

219

"""

220

pass

221

222

def get(self) -> LiveRequest:

223

"""

224

Get a request from the queue.

225

226

Returns:

227

LiveRequest: Next request in queue

228

"""

229

pass

230

```

231

232

## Usage Examples

233

234

### Creating a Simple Agent

235

236

```python

237

from google.adk.agents import Agent

238

from google.adk.tools import google_search

239

240

agent = Agent(

241

name="research_assistant",

242

model="gemini-2.0-flash",

243

instruction="You are a research assistant. Use web search to find accurate information.",

244

description="An agent that helps with research tasks",

245

tools=[google_search]

246

)

247

```

248

249

### Multi-Agent System

250

251

```python

252

from google.adk.agents import LlmAgent

253

254

# Create specialized agents

255

researcher = LlmAgent(

256

name="researcher",

257

model="gemini-2.0-flash",

258

instruction="Research topics thoroughly using available tools.",

259

tools=[google_search]

260

)

261

262

writer = LlmAgent(

263

name="writer",

264

model="gemini-2.0-flash",

265

instruction="Write clear, well-structured content based on research."

266

)

267

268

# Create coordinator

269

coordinator = LlmAgent(

270

name="content_creator",

271

model="gemini-2.0-flash",

272

description="Coordinates research and writing to create high-quality content.",

273

sub_agents=[researcher, writer]

274

)

275

```

276

277

### Sequential Workflow

278

279

```python

280

from google.adk.agents import SequentialAgent, LlmAgent

281

282

# Create agents for each step

283

data_collector = LlmAgent(name="collector", model="gemini-2.0-flash", ...)

284

data_processor = LlmAgent(name="processor", model="gemini-2.0-flash", ...)

285

report_generator = LlmAgent(name="reporter", model="gemini-2.0-flash", ...)

286

287

# Create sequential workflow

288

workflow = SequentialAgent(

289

name="data_analysis_workflow",

290

agents=[data_collector, data_processor, report_generator]

291

)

292

```

293

294

### Loop Agent for Iterative Tasks

295

296

```python

297

from google.adk.agents import LoopAgent, LlmAgent

298

299

# Create base agent

300

iterative_agent = LlmAgent(

301

name="problem_solver",

302

model="gemini-2.0-flash",

303

instruction="Solve problems step by step, refining your approach with each iteration."

304

)

305

306

# Wrap in loop agent

307

loop_solver = LoopAgent(

308

name="iterative_solver",

309

agent=iterative_agent,

310

max_iterations=5

311

)

312

```