diff --git a/docs/agents/custom-agents.md b/docs/agents/custom-agents.md index 941b8cd22f..ea8dc1a6e8 100644 --- a/docs/agents/custom-agents.md +++ b/docs/agents/custom-agents.md @@ -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 { @@ -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 { @@ -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 diff --git a/docs/context/index.md b/docs/context/index.md index 82651d7a84..d8c1a0ab93 100644 --- a/docs/context/index.md +++ b/docs/context/index.md @@ -1376,10 +1376,12 @@ Access relevant information from the past or external sources. async function findRelatedInfo(context: Context, topic: string): Promise> { 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.' }; diff --git a/docs/plugins/index.md b/docs/plugins/index.md index 09c052e782..29606b4a45 100644 --- a/docs/plugins/index.md +++ b/docs/plugins/index.md @@ -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 { this.agentCount++; console.log(`[Plugin] Agent run count: ${this.agentCount}`); @@ -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 { this.llmRequestCount++; console.log(`[Plugin] LLM request count: ${this.llmRequestCount}`); diff --git a/docs/tools-custom/mcp-tools.md b/docs/tools-custom/mcp-tools.md index 22cdb4897e..c36f9e234c 100644 --- a/docs/tools-custom/mcp-tools.md +++ b/docs/tools-custom/mcp-tools.md @@ -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" + } + } } }) ], diff --git a/docs/workflows/patterns.md b/docs/workflows/patterns.md index 94d897b3a0..9029c2af6a 100644 --- a/docs/workflows/patterns.md +++ b/docs/workflows/patterns.md @@ -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({