feat(core): Standardize Tool and Agent Invocation constructors (Phase 2) (#15775)

This commit is contained in:
Abhi
2026-01-04 15:51:23 -05:00
committed by GitHub
parent eec5d5ebf8
commit 90be9c3587
23 changed files with 140 additions and 44 deletions
@@ -100,6 +100,8 @@ describe('DelegateToAgentTool', () => {
config,
{ arg1: 'valid' },
messageBus,
mockAgentDef.name,
mockAgentDef.name,
);
});
@@ -127,12 +127,17 @@ export class DelegateToAgentTool extends BaseDeclarativeTool<
protected createInvocation(
params: DelegateParams,
messageBus?: MessageBus,
_toolName?: string,
_toolDisplayName?: string,
): ToolInvocation<DelegateParams, ToolResult> {
return new DelegateInvocation(
params,
this.registry,
this.config,
this.messageBus,
messageBus ?? this.messageBus,
_toolName,
_toolDisplayName,
);
}
}
@@ -146,8 +151,15 @@ class DelegateInvocation extends BaseToolInvocation<
private readonly registry: AgentRegistry,
private readonly config: Config,
messageBus?: MessageBus,
_toolName?: string,
_toolDisplayName?: string,
) {
super(params, messageBus, DELEGATE_TO_AGENT_TOOL_NAME);
super(
params,
messageBus,
_toolName ?? DELEGATE_TO_AGENT_TOOL_NAME,
_toolDisplayName,
);
}
getDescription(): string {
+8 -1
View File
@@ -44,8 +44,15 @@ export class LocalSubagentInvocation extends BaseToolInvocation<
private readonly config: Config,
params: AgentInputs,
messageBus?: MessageBus,
_toolName?: string,
_toolDisplayName?: string,
) {
super(params, messageBus, definition.name, definition.displayName);
super(
params,
messageBus,
_toolName ?? definition.name,
_toolDisplayName ?? definition.displayName,
);
}
/**
@@ -26,8 +26,15 @@ export class RemoteAgentInvocation extends BaseToolInvocation<
private readonly definition: RemoteAgentDefinition,
params: AgentInputs,
messageBus?: MessageBus,
_toolName?: string,
_toolDisplayName?: string,
) {
super(params, messageBus, definition.name, definition.displayName);
super(
params,
messageBus,
_toolName ?? definition.name,
_toolDisplayName ?? definition.displayName,
);
}
getDescription(): string {
@@ -120,6 +120,8 @@ describe('SubagentToolWrapper', () => {
mockConfig,
params,
undefined,
mockDefinition.name,
mockDefinition.displayName,
);
});
@@ -139,6 +141,8 @@ describe('SubagentToolWrapper', () => {
mockConfig,
params,
mockMessageBus,
mockDefinition.name,
mockDefinition.displayName,
);
});
@@ -67,17 +67,30 @@ export class SubagentToolWrapper extends BaseDeclarativeTool<
*/
protected createInvocation(
params: AgentInputs,
messageBus?: MessageBus,
_toolName?: string,
_toolDisplayName?: string,
): ToolInvocation<AgentInputs, ToolResult> {
const definition = this.definition;
const effectiveMessageBus = messageBus ?? this.messageBus;
if (definition.kind === 'remote') {
return new RemoteAgentInvocation(definition, params, this.messageBus);
return new RemoteAgentInvocation(
definition,
params,
effectiveMessageBus,
_toolName,
_toolDisplayName,
);
}
return new LocalSubagentInvocation(
definition,
this.config,
params,
this.messageBus,
effectiveMessageBus,
_toolName,
_toolDisplayName,
);
}
}