Fix issue where config was undefined. (#22397)

This commit is contained in:
Christian Gunderman
2026-03-14 01:36:25 +00:00
committed by GitHub
parent 604d4ded8d
commit 64c50d32ac
3 changed files with 32 additions and 2 deletions

View File

@@ -120,4 +120,25 @@ describe('agent-scheduler', () => {
expect(schedulerConfig.toolRegistry).toBe(agentRegistry);
expect(schedulerConfig.toolRegistry).not.toBe(mainRegistry);
});
it('should create an AgentLoopContext that has a defined .config property', async () => {
const mockConfig = {
messageBus: mockMessageBus,
toolRegistry: mockToolRegistry,
promptId: 'test-prompt',
} as unknown as Mocked<Config>;
const options = {
schedulerId: 'subagent-1',
toolRegistry: mockToolRegistry as unknown as ToolRegistry,
signal: new AbortController().signal,
};
await scheduleAgentTools(mockConfig as unknown as Config, [], options);
const schedulerContext = vi.mocked(Scheduler).mock.calls[0][0].context;
expect(schedulerContext.config).toBeDefined();
expect(schedulerContext.config.promptId).toBe('test-prompt');
expect(schedulerContext.toolRegistry).toBe(mockToolRegistry);
});
});

View File

@@ -67,8 +67,17 @@ export async function scheduleAgentTools(
configurable: true,
});
const schedulerContext = {
config: agentConfig,
promptId: config.promptId,
toolRegistry,
messageBus: toolRegistry.messageBus,
geminiClient: config.geminiClient,
sandboxManager: config.sandboxManager,
};
const scheduler = new Scheduler({
context: agentConfig,
context: schedulerContext,
messageBus: toolRegistry.messageBus,
getPreferredEditor: getPreferredEditor ?? (() => undefined),
schedulerId,

View File

@@ -133,7 +133,7 @@ export class CoreToolScheduler {
this.onAllToolCallsComplete = options.onAllToolCallsComplete;
this.onToolCallsUpdate = options.onToolCallsUpdate;
this.getPreferredEditor = options.getPreferredEditor;
this.toolExecutor = new ToolExecutor(this.context.config);
this.toolExecutor = new ToolExecutor(this.context);
this.toolModifier = new ToolModificationHandler();
// Subscribe to message bus for ASK_USER policy decisions