feat(core): Fully migrate packages/core to AgentLoopContext. (#22115)

This commit is contained in:
joshualitt
2026-03-12 18:56:31 -07:00
committed by GitHub
parent 1d2585dba6
commit de656f01d7
53 changed files with 522 additions and 292 deletions
+5 -5
View File
@@ -17,12 +17,12 @@ import {
import { ToolErrorType } from './tool-error.js';
import { getErrorMessage, isAbortError } from '../utils/errors.js';
import { type Config } from '../config/config.js';
import { getResponseText } from '../utils/partUtils.js';
import { debugLogger } from '../utils/debugLogger.js';
import { WEB_SEARCH_DEFINITION } from './definitions/coreTools.js';
import { resolveToolDeclaration } from './definitions/resolver.js';
import { LlmRole } from '../telemetry/llmRole.js';
import type { AgentLoopContext } from '../config/agent-loop-context.js';
interface GroundingChunkWeb {
uri?: string;
@@ -71,7 +71,7 @@ class WebSearchToolInvocation extends BaseToolInvocation<
WebSearchToolResult
> {
constructor(
private readonly config: Config,
private readonly context: AgentLoopContext,
params: WebSearchToolParams,
messageBus: MessageBus,
_toolName?: string,
@@ -85,7 +85,7 @@ class WebSearchToolInvocation extends BaseToolInvocation<
}
async execute(signal: AbortSignal): Promise<WebSearchToolResult> {
const geminiClient = this.config.getGeminiClient();
const geminiClient = this.context.geminiClient;
try {
const response = await geminiClient.generateContent(
@@ -207,7 +207,7 @@ export class WebSearchTool extends BaseDeclarativeTool<
static readonly Name = WEB_SEARCH_TOOL_NAME;
constructor(
private readonly config: Config,
private readonly context: AgentLoopContext,
messageBus: MessageBus,
) {
super(
@@ -243,7 +243,7 @@ export class WebSearchTool extends BaseDeclarativeTool<
_toolDisplayName?: string,
): ToolInvocation<WebSearchToolParams, WebSearchToolResult> {
return new WebSearchToolInvocation(
this.config,
this.context.config,
params,
messageBus ?? this.messageBus,
_toolName,