Skip to content

Commit b915a77

Browse files
committed
fix: Resolve agent lint, test build errors, enable test linting
1 parent 16c26fa commit b915a77

File tree

3 files changed

+18
-21
lines changed

3 files changed

+18
-21
lines changed

eslint.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ module.exports = [
1616
"*.config.js", // Ignores other .config.js files (e.g., vitest.config.js)
1717
"*.config.ts", // Ignores .config.ts files
1818
"scripts/",
19-
"src/lib/__tests__/**/*.ts", // More specific for these paths
20-
"src/tests/**/*.ts" // More specific for these paths
19+
// "src/lib/__tests__/**/*.ts", // Re-enable linting for test files
20+
// "src/tests/**/*.ts" // Re-enable linting for test files
2121
],
2222
},
2323

src/lib/__tests__/query-refinement.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { describe, it, expect, vi, beforeEach, afterEach, beforeAll, type Mock, type MockedFunction, afterAll } from 'vitest';
1+
import { describe, it, expect, vi, beforeEach, afterEach, beforeAll, type Mock, type MockedFunction } from 'vitest';
22
import { QdrantClient } from '@qdrant/js-client-rest';
33

44
// 2. Mock external dependencies FIRST
@@ -63,7 +63,7 @@ describe('Query Refinement Tests', () => {
6363

6464
describe('searchWithRefinement', () => {
6565
let searchWithRefinementSUT_local: (typeof import('../query-refinement.js'))['searchWithRefinement'];
66-
let mockRefineQuery_for_searchTest: Mock<[string, DetailedQdrantSearchResult[], number], string>;
66+
let mockRefineQuery_for_searchTest: MockedFunction<(query: string, results: DetailedQdrantSearchResult[], currentRelevance: number) => string>;
6767

6868
beforeEach(async () => {
6969
vi.resetModules(); // Ensure clean state for vi.doMock
@@ -181,9 +181,9 @@ describe('Query Refinement Tests', () => {
181181

182182
describe('refineQuery (main dispatcher - testing original logic)', () => {
183183
let refineQuerySUT_local: (typeof import('../query-refinement.js'))['refineQuery'];
184-
let mockBroadenQuery_local: Mock<[string], string>;
185-
let mockFocusQuery_local: Mock<[string, DetailedQdrantSearchResult[]], string>;
186-
let mockTweakQuery_local: Mock<[string, DetailedQdrantSearchResult[]], string>;
184+
let mockBroadenQuery_local: MockedFunction<(query: string) => string>;
185+
let mockFocusQuery_local: MockedFunction<(query: string, results: DetailedQdrantSearchResult[]) => string>;
186+
let mockTweakQuery_local: MockedFunction<(query: string, results: DetailedQdrantSearchResult[]) => string>;
187187

188188
beforeEach(async () => {
189189
vi.resetModules(); // Ensure clean state for vi.doMock

src/lib/agent.ts

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,22 +1189,19 @@ export async function runAgentLoop(
11891189
agentState.finalResponse = "I apologize, but I couldn't complete the full analysis due to a timeout. " +
11901190
"Here's what I found so far: " +
11911191
agentState.steps.map((s: AgentStep) => {
1192-
let displayOutput: string;
1193-
if (typeof s.output === 'string') {
1194-
displayOutput = s.output;
1195-
} else if (s.output === null || s.output === undefined) {
1196-
// Explicitly convert null or undefined to their string representations
1197-
displayOutput = String(s.output);
1192+
const toolName = s.tool; // s.tool is already a string
1193+
let outputString: string;
1194+
if (typeof s.output === 'object' && s.output !== null) {
1195+
try {
1196+
outputString = JSON.stringify(s.output);
1197+
} catch {
1198+
outputString = String(s.output); // Fallback for non-serializable objects
1199+
}
11981200
} else {
1199-
// For other types (objects, arrays, functions, etc.)
1200-
// Try JSON.stringify first. If it returns undefined (e.g., for a function),
1201-
// then fallback to String(s.output).
1202-
const jsonStringified = JSON.stringify(s.output);
1203-
displayOutput = jsonStringified === undefined ? String(s.output) : jsonStringified;
1201+
outputString = String(s.output); // Handles primitives, null, undefined
12041202
}
1205-
// Ensure we have a string, then take a substring.
1206-
const safePreviewText = (displayOutput || '').substring(0, 200);
1207-
return `Used ${s.tool} and found: ${safePreviewText}...`;
1203+
const safePreviewText = (outputString || 'No output').substring(0, 200);
1204+
return `Used ${toolName} and found: ${safePreviewText}...`;
12081205
}).join("\n\n");
12091206
}
12101207
}

0 commit comments

Comments
 (0)