mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-13 23:01:09 -07:00
feat(core): experimental in-progress steering hints (2 of 2) (#19307)
This commit is contained in:
@@ -148,4 +148,129 @@ describe('SubAgentInvocation', () => {
|
||||
updateOutput,
|
||||
);
|
||||
});
|
||||
|
||||
describe('withUserHints', () => {
|
||||
it('should NOT modify query for local agents', async () => {
|
||||
mockConfig = makeFakeConfig({ modelSteering: true });
|
||||
mockConfig.userHintService.addUserHint('Test Hint');
|
||||
|
||||
const tool = new SubagentTool(testDefinition, mockConfig, mockMessageBus);
|
||||
const params = { query: 'original query' };
|
||||
// @ts-expect-error - accessing private method for testing
|
||||
const invocation = tool.createInvocation(params, mockMessageBus);
|
||||
|
||||
// @ts-expect-error - accessing private method for testing
|
||||
const hintedParams = invocation.withUserHints(params);
|
||||
|
||||
expect(hintedParams.query).toBe('original query');
|
||||
});
|
||||
|
||||
it('should NOT modify query for remote agents if model steering is disabled', async () => {
|
||||
mockConfig = makeFakeConfig({ modelSteering: false });
|
||||
mockConfig.userHintService.addUserHint('Test Hint');
|
||||
|
||||
const tool = new SubagentTool(
|
||||
testRemoteDefinition,
|
||||
mockConfig,
|
||||
mockMessageBus,
|
||||
);
|
||||
const params = { query: 'original query' };
|
||||
// @ts-expect-error - accessing private method for testing
|
||||
const invocation = tool.createInvocation(params, mockMessageBus);
|
||||
|
||||
// @ts-expect-error - accessing private method for testing
|
||||
const hintedParams = invocation.withUserHints(params);
|
||||
|
||||
expect(hintedParams.query).toBe('original query');
|
||||
});
|
||||
|
||||
it('should NOT modify query for remote agents if there are no hints', async () => {
|
||||
mockConfig = makeFakeConfig({ modelSteering: true });
|
||||
|
||||
const tool = new SubagentTool(
|
||||
testRemoteDefinition,
|
||||
mockConfig,
|
||||
mockMessageBus,
|
||||
);
|
||||
const params = { query: 'original query' };
|
||||
// @ts-expect-error - accessing private method for testing
|
||||
const invocation = tool.createInvocation(params, mockMessageBus);
|
||||
|
||||
// @ts-expect-error - accessing private method for testing
|
||||
const hintedParams = invocation.withUserHints(params);
|
||||
|
||||
expect(hintedParams.query).toBe('original query');
|
||||
});
|
||||
|
||||
it('should prepend hints to query for remote agents when hints exist and steering is enabled', async () => {
|
||||
mockConfig = makeFakeConfig({ modelSteering: true });
|
||||
|
||||
const tool = new SubagentTool(
|
||||
testRemoteDefinition,
|
||||
mockConfig,
|
||||
mockMessageBus,
|
||||
);
|
||||
const params = { query: 'original query' };
|
||||
// @ts-expect-error - accessing private method for testing
|
||||
const invocation = tool.createInvocation(params, mockMessageBus);
|
||||
|
||||
mockConfig.userHintService.addUserHint('Hint 1');
|
||||
mockConfig.userHintService.addUserHint('Hint 2');
|
||||
|
||||
// @ts-expect-error - accessing private method for testing
|
||||
const hintedParams = invocation.withUserHints(params);
|
||||
|
||||
expect(hintedParams.query).toContain('Hint 1');
|
||||
expect(hintedParams.query).toContain('Hint 2');
|
||||
expect(hintedParams.query).toMatch(/original query$/);
|
||||
});
|
||||
|
||||
it('should NOT include legacy hints added before the invocation was created', async () => {
|
||||
mockConfig = makeFakeConfig({ modelSteering: true });
|
||||
mockConfig.userHintService.addUserHint('Legacy Hint');
|
||||
|
||||
const tool = new SubagentTool(
|
||||
testRemoteDefinition,
|
||||
mockConfig,
|
||||
mockMessageBus,
|
||||
);
|
||||
const params = { query: 'original query' };
|
||||
|
||||
// Creation of invocation captures the current hint state
|
||||
// @ts-expect-error - accessing private method for testing
|
||||
const invocation = tool.createInvocation(params, mockMessageBus);
|
||||
|
||||
// Verify no hints are present yet
|
||||
// @ts-expect-error - accessing private method for testing
|
||||
let hintedParams = invocation.withUserHints(params);
|
||||
expect(hintedParams.query).toBe('original query');
|
||||
|
||||
// Add a new hint after creation
|
||||
mockConfig.userHintService.addUserHint('New Hint');
|
||||
// @ts-expect-error - accessing private method for testing
|
||||
hintedParams = invocation.withUserHints(params);
|
||||
|
||||
expect(hintedParams.query).toContain('New Hint');
|
||||
expect(hintedParams.query).not.toContain('Legacy Hint');
|
||||
});
|
||||
|
||||
it('should NOT modify query if query is missing or not a string', async () => {
|
||||
mockConfig = makeFakeConfig({ modelSteering: true });
|
||||
mockConfig.userHintService.addUserHint('Hint');
|
||||
|
||||
const tool = new SubagentTool(
|
||||
testRemoteDefinition,
|
||||
mockConfig,
|
||||
mockMessageBus,
|
||||
);
|
||||
const params = { other: 'param' };
|
||||
// @ts-expect-error - accessing private method for testing
|
||||
const invocation = tool.createInvocation(params, mockMessageBus);
|
||||
|
||||
// @ts-expect-error - accessing private method for testing
|
||||
const hintedParams = invocation.withUserHints(params);
|
||||
|
||||
expect(hintedParams).toEqual(params);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user