Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions docs/agents/custom-agents.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,8 @@ The foundation for structuring multi-agent systems is the parent-child relations

```typescript
// Conceptual Example: Defining Hierarchy
import { LlmAgent, BaseAgent, InvocationContext } from '@google/adk';
import type { Event, createEventActions } from '@google/adk';
import { LlmAgent, BaseAgent, InvocationContext, createEventActions } from '@google/adk';
import type { Event } from '@google/adk';

class TaskExecutorAgent extends BaseAgent {
async *runAsyncImpl(context: InvocationContext): AsyncGenerator<Event, void, void> {
Expand Down Expand Up @@ -568,8 +568,8 @@ ADK includes specialized agents derived from `BaseAgent` that don't perform task

```typescript
// Conceptual Example: Loop with Condition
import { LoopAgent, LlmAgent, BaseAgent, InvocationContext } from '@google/adk';
import type { Event, createEventActions, EventActions } from '@google/adk';
import { LoopAgent, LlmAgent, BaseAgent, InvocationContext, createEvent, createEventActions } from '@google/adk';
import type { Event } from '@google/adk';

class CheckConditionAgent extends BaseAgent { // Custom agent to check state
async *runAsyncImpl(ctx: InvocationContext): AsyncGenerator<Event> {
Expand Down Expand Up @@ -905,8 +905,9 @@ Allows an [`LlmAgent`](llm-agents.md) to treat another `BaseAgent` instance as a

```typescript
// Conceptual Setup: Agent as a Tool
import { LlmAgent, BaseAgent, AgentTool, InvocationContext } from '@google/adk';
import type { Part, createEvent, Event } from '@google/genai';
import { LlmAgent, BaseAgent, AgentTool, InvocationContext, createEvent } from '@google/adk';
import type { Event } from '@google/adk';
import type { Part } from '@google/genai';

// Define a target agent (could be LlmAgent or custom BaseAgent)
class ImageGeneratorAgent extends BaseAgent { // Example custom agent
Expand Down
10 changes: 6 additions & 4 deletions docs/context/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -1376,10 +1376,12 @@ Access relevant information from the past or external sources.
async function findRelatedInfo(context: Context, topic: string): Promise<Record<string, string>> {
try {
const searchResults = await context.searchMemory(`Information about ${topic}`);
if (searchResults.results?.length) {
console.log(`Found ${searchResults.results.length} memory results for '${topic}'`);
// Process searchResults.results
const topResultText = searchResults.results[0].text;
if (searchResults.memories.length) {
console.log(`Found ${searchResults.memories.length} memory results for '${topic}'`);
// Each entry is a MemoryEntry: its text lives on `content.parts`.
const topResultText = searchResults.memories[0].content.parts
?.map((part) => part.text ?? '')
.join('') ?? '';
return { memory_snippet: topResultText };
} else {
return { message: 'No relevant memories found.' };
Expand Down
6 changes: 2 additions & 4 deletions docs/plugins/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,7 @@ methods, as shown in the following code example:
* Count agent runs.
*/
async beforeAgentCallback(
agent: BaseAgent,
context: Context
{ agent, callbackContext }: { agent: BaseAgent; callbackContext: Context }
): Promise<Content | undefined> {
this.agentCount++;
console.log(`[Plugin] Agent run count: ${this.agentCount}`);
Expand All @@ -152,8 +151,7 @@ methods, as shown in the following code example:
* Count LLM requests.
*/
async beforeModelCallback(
context: Context,
llmRequest: LlmRequest
{ callbackContext, llmRequest }: { callbackContext: Context; llmRequest: LlmRequest }
): Promise<LlmResponse | undefined> {
this.llmRequestCount++;
console.log(`[Plugin] LLM request count: ${this.llmRequestCount}`);
Expand Down
16 changes: 10 additions & 6 deletions docs/tools-custom/mcp-tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -501,14 +501,18 @@ export const rootAgent = new LlmAgent({
description: "A helpful assistant for planning travel.",
tools: [
new MCPToolset({
// Using SseConnectionParams to connect to the remote Grounding Lite service,
// Connects to the remote Grounding Lite service over streamable HTTP,
// mirroring Python's StreamableHTTPConnectionParams.
type: "SseConnectionParams",
type: "StreamableHTTPConnectionParams",
url: "https://mapstools.googleapis.com/mcp",
headers: {
"X-Goog-Api-Key": googleMapsApiKey,
"Content-Type": "application/json",
"Accept": "application/json, text/event-stream"
transportOptions: {
requestInit: {
headers: {
"X-Goog-Api-Key": googleMapsApiKey,
"Content-Type": "application/json",
"Accept": "application/json, text/event-stream"
}
}
}
})
],
Expand Down
4 changes: 2 additions & 2 deletions docs/workflows/patterns.md
Original file line number Diff line number Diff line change
Expand Up @@ -656,8 +656,8 @@ your project requirements before committing to a full implementation.

```typescript
// Conceptual Code: Iterative Code Refinement
import { LoopAgent, LlmAgent, BaseAgent, InvocationContext } from '@google/adk';
import type { Event, createEvent, createEventActions } from '@google/genai';
import { LoopAgent, LlmAgent, BaseAgent, InvocationContext, createEvent, createEventActions } from '@google/adk';
import type { Event } from '@google/adk';

// Agent to generate/refine code based on state['current_code'] and state['requirements']
const codeRefiner = new LlmAgent({
Expand Down
Loading