Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions packages/core/src/agents/agent-scheduler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
11 changes: 10 additions & 1 deletion packages/core/src/agents/agent-scheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/core/coreToolScheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading