Skip to content

Commit a98bd12

Browse files
committed
fix: Knowledge Base Infrastructure & Provider Stabilization (#9825)
1 parent efbda3c commit a98bd12

2 files changed

Lines changed: 15 additions & 16 deletions

File tree

ai/provider/Gemini.mjs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,15 @@ class GeminiProvider extends Base {
4949
// Deep clone to avoid mutating original schema
5050
const parameters = JSON.parse(JSON.stringify(tool.inputSchema || { type: 'object', properties: {} }));
5151

52-
// Gemini requires type names to be uppercase (e.g. 'OBJECT', 'STRING')
5352
const uppercaseTypes = (obj) => {
5453
if (obj && typeof obj === 'object') {
5554
if (typeof obj.type === 'string') {
5655
obj.type = obj.type.toUpperCase();
5756
}
57+
// Gemini does not support additionalProperties in the tool schema
58+
if (obj.hasOwnProperty('additionalProperties')) {
59+
delete obj.additionalProperties;
60+
}
5861
for (const key in obj) {
5962
uppercaseTypes(obj[key]);
6063
}

test/playwright/unit/ai/agent/Librarian.spec.mjs

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ test.describe('Librarian Sub-Agent Orchestration', () => {
3737
});
3838

3939
test('Primary Agent delegates research task to Librarian via Loop tool execution', async () => {
40+
// Since this now tests actual inference and GraphRAG IO, we increase the timeout block
41+
test.setTimeout(180_000);
42+
4043
// Skip test in CI environments without API keys
4144
test.skip(!process.env.GEMINI_API_KEY, 'Skipping: GEMINI_API_KEY not found');
4245

@@ -48,7 +51,7 @@ test.describe('Librarian Sub-Agent Orchestration', () => {
4851

4952
await primaryAgent.initAsync();
5053

51-
// We wrap the delegate method to verify it was executed correctly
54+
// We wrap the delegate method to verify it was executed correctly natively
5255
let delegateCalled = false;
5356
let delegatedAgentAlias = null;
5457

@@ -57,33 +60,26 @@ test.describe('Librarian Sub-Agent Orchestration', () => {
5760
delegateCalled = true;
5861
delegatedAgentAlias = profileName;
5962

60-
// To ensure test speed and reliability without actually querying the real MCP graph,
61-
// we mock the sub-agent's response. In a true integration test against an active Graph DB,
62-
// we would `return await originalDelegate.call(this, profileName, request);`
63-
return 'Mock Synthesis: Neo.component.Base is the foundation for all UI components.';
64-
};
65-
66-
// We MUST mock the ContextAssembler to prevent it from attempting real DB queries
67-
// via thick-client connections to ChromaDB, ensuring this remains a decoupled unit test.
68-
primaryAgent.loop.assembler.assemble = async function({systemPrompt, userQuery}) {
69-
return {
70-
system: systemPrompt,
71-
messages: [{ role: 'user', content: userQuery }]
72-
};
63+
// Execute the true delegation and sub-agent boot
64+
return await originalDelegate.call(this, profileName, request);
7365
};
7466

7567
// Since delegate_task is now injected natively into the Loop's tools array,
7668
// we can simply instruct the model to use the tool, and it will trigger it natively.
7769
const event = {
7870
type: 'user:input',
7971
priority: 'high',
80-
data: 'You must research the architectural purpose of Neo.component.Base. You do not have the context. Delegate this to the "librarian" sub-agent using the delegate_task tool. Once you get the result, formulate your final answer.'
72+
data: 'You must research the exact architectural purpose of Neo.component.Base. You do not have the context. Delegate this to the "librarian" sub-agent using the delegate_task tool. Once you get the result, formulate your final answer. Please include specific details retrieved from the architectural context.'
8173
};
8274

8375
// Bypass the scheduler and force synchronous processing for the test environment
8476
const finalAnswer = await primaryAgent.loop.processEvent(event);
8577

78+
console.log('\n--- E2E GraphRAG Synthesis Output ---\n', finalAnswer, '\n-------------------------------------\n');
79+
8680
expect(delegateCalled).toBeTruthy();
8781
expect(delegatedAgentAlias).toBe('librarian');
82+
expect(typeof finalAnswer).toBe('string');
83+
expect(finalAnswer.length).toBeGreaterThan(50);
8884
});
8985
});

0 commit comments

Comments
 (0)