Disallow redundant typecasts. (#15030)

This commit is contained in:
Christian Gunderman
2025-12-12 17:43:43 -08:00
committed by GitHub
parent fcc3b2b5ec
commit 942bcfc61e
86 changed files with 235 additions and 371 deletions
+3 -3
View File
@@ -317,7 +317,7 @@ describe('AgentExecutor', () => {
onActivity,
);
const agentRegistry = executor['toolRegistry'] as ToolRegistry;
const agentRegistry = executor['toolRegistry'];
expect(agentRegistry).not.toBe(parentToolRegistry);
expect(agentRegistry.getAllToolNames()).toEqual(
@@ -754,7 +754,7 @@ describe('AgentExecutor', () => {
expect(turn2Parts).toBeDefined();
expect(turn2Parts).toHaveLength(1);
expect((turn2Parts as Part[])![0]).toEqual(
expect((turn2Parts as Part[])[0]).toEqual(
expect.objectContaining({
functionResponse: expect.objectContaining({
name: TASK_COMPLETE_TOOL_NAME,
@@ -944,7 +944,7 @@ describe('AgentExecutor', () => {
const turn2Params = getMockMessageParams(1);
const parts = turn2Params.message;
expect(parts).toBeDefined();
expect((parts as Part[])![0]).toEqual(
expect((parts as Part[])[0]).toEqual(
expect.objectContaining({
functionResponse: expect.objectContaining({
id: badCallId,
+3 -3
View File
@@ -707,7 +707,7 @@ export class AgentExecutor<TOutput extends z.ZodTypeAny> {
for (const [index, functionCall] of functionCalls.entries()) {
const callId = functionCall.id ?? `${promptId}-${index}`;
const args = (functionCall.args ?? {}) as Record<string, unknown>;
const args = functionCall.args ?? {};
this.emitActivity('TOOL_CALL_START', {
name: functionCall.name,
@@ -918,10 +918,10 @@ export class AgentExecutor<TOutput extends z.ZodTypeAny> {
toolNamesToLoad.push(toolRef);
} else if (typeof toolRef === 'object' && 'schema' in toolRef) {
// Tool instance with an explicit schema property.
toolsList.push(toolRef.schema as FunctionDeclaration);
toolsList.push(toolRef.schema);
} else {
// Raw `FunctionDeclaration` object.
toolsList.push(toolRef as FunctionDeclaration);
toolsList.push(toolRef);
}
}
// Add schemas from tools that were registered by name.