diff --git a/packages/core/src/agents/local-executor.test.ts b/packages/core/src/agents/local-executor.test.ts index f8ddef3689..58dd19fd9b 100644 --- a/packages/core/src/agents/local-executor.test.ts +++ b/packages/core/src/agents/local-executor.test.ts @@ -49,6 +49,7 @@ vi.mock('../tools/mcp-client-manager.js', () => ({ })); import { debugLogger } from '../utils/debugLogger.js'; +import { runWithToolCallContext } from '../utils/toolCallContext.js'; import { LocalAgentExecutor, type ActivityCallback } from './local-executor.js'; import { makeFakeConfig } from '../test-utils/config.js'; import { ToolRegistry } from '../tools/tool-registry.js'; @@ -708,21 +709,19 @@ describe('LocalAgentExecutor', () => { expect(agentRegistry.getTool(MOCK_TOOL_NOT_ALLOWED.name)).toBeUndefined(); }); - it('should use parentPromptId from context to create agentId', async () => { - const parentId = 'parent-id'; - Object.defineProperty(mockConfig, 'promptId', { - get: () => parentId, - configurable: true, - }); - + it('should not include parentCallId in agentId even when available', async () => { const definition = createTestDefinition(); - const executor = await LocalAgentExecutor.create( - definition, - mockConfig, - onActivity, + const parentCallId = 'parent-call-123'; + + const executor = await runWithToolCallContext( + { callId: parentCallId, schedulerId: 'test-scheduler' }, + () => LocalAgentExecutor.create(definition, mockConfig, onActivity), ); - expect(executor['agentId']).toBeDefined(); + expect(executor['agentId']).not.toContain(parentCallId); + expect(executor['agentId']).toMatch( + /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i, + ); }); it('should correctly apply templates to initialMessages', async () => { diff --git a/packages/core/src/agents/local-executor.ts b/packages/core/src/agents/local-executor.ts index 4630ced5e5..ab2fad18d2 100644 --- a/packages/core/src/agents/local-executor.ts +++ b/packages/core/src/agents/local-executor.ts @@ -6,6 +6,7 @@ import { type AgentLoopContext } from '../config/agent-loop-context.js'; import { reportError } from '../utils/errorReporting.js'; +import { randomUUID } from 'node:crypto'; import { ApprovalMode } from '../policy/types.js'; import { GeminiChat, StreamEventType } from '../core/geminiChat.js'; import { @@ -315,7 +316,7 @@ export class LocalAgentExecutor { this.parentCallId = parentCallId; this.cache = new LRUCache(10); - this.agentId = Math.random().toString(36).slice(2, 8); + this.agentId = randomUUID(); } /** diff --git a/packages/sdk/src/skills.integration.test.ts b/packages/sdk/src/skills.integration.test.ts index aaad9f3676..385304a97c 100644 --- a/packages/sdk/src/skills.integration.test.ts +++ b/packages/sdk/src/skills.integration.test.ts @@ -55,7 +55,7 @@ describe('GeminiCliAgent Skills Integration', () => { // Expect pirate speak expect(responseText.toLowerCase()).toContain('arrr'); - }, 60000); + }, 120000); it('loads and activates a skill from a root', async () => { const goldenFile = getGoldenPath('skill-root-success'); @@ -88,5 +88,5 @@ describe('GeminiCliAgent Skills Integration', () => { // Expect confirmation or pirate speak expect(responseText.toLowerCase()).toContain('arrr'); - }, 60000); + }, 120000); }); diff --git a/packages/sdk/src/tool.integration.test.ts b/packages/sdk/src/tool.integration.test.ts index 28c01c3ca2..25257ae2df 100644 --- a/packages/sdk/src/tool.integration.test.ts +++ b/packages/sdk/src/tool.integration.test.ts @@ -57,7 +57,7 @@ describe('GeminiCliAgent Tool Integration', () => { .join(''); expect(responseText).toContain('8'); - }); + }, 20000); it('handles ModelVisibleError correctly', async () => { const goldenFile = getGoldenPath('tool-error-recovery'); @@ -103,7 +103,7 @@ describe('GeminiCliAgent Tool Integration', () => { // The model should see the error "Tool failed visibly" and report it back. expect(responseText).toContain('Tool failed visibly'); - }); + }, 20000); it('handles sendErrorsToModel: true correctly', async () => { const goldenFile = getGoldenPath('tool-catchall-error'); @@ -145,5 +145,5 @@ describe('GeminiCliAgent Tool Integration', () => { // The model should report the caught standard error. expect(responseText.toLowerCase()).toContain('error'); - }); + }, 20000); });