From de2d0c187ffe460b3fe75849f787277b07a3fe18 Mon Sep 17 00:00:00 2001 From: Nate Date: Sat, 5 Jul 2025 09:53:53 -0700 Subject: [PATCH 1/2] parse incorrectly formatted vectors so we can salvage broken indexes --- core/indexing/LanceDbIndex.ts | 19 ++++++++++++++++++- gui/src/redux/slices/sessionSlice.ts | 1 - 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/core/indexing/LanceDbIndex.ts b/core/indexing/LanceDbIndex.ts index facaba2f1..e01518629 100644 --- a/core/indexing/LanceDbIndex.ts +++ b/core/indexing/LanceDbIndex.ts @@ -234,6 +234,23 @@ export class LanceDbIndex implements CodebaseIndex { return results; } + /** + * Due to a bug in indexing, some indexes have vectors + * without the surrounding []. These would fail to parse + * but this allows such existing indexes to function properly + */ + private parseVector(vector: string): number[] { + try { + return JSON.parse(vector); + } catch (err) { + try { + return JSON.parse(`[${vector}]`); + } catch (err2) { + throw new Error(`Failed to parse vector: ${vector}`, { cause: err2 }); + } + } + } + async *update( tag: IndexTag, results: RefreshIndexResults, @@ -297,7 +314,7 @@ export class LanceDbIndex implements CodebaseIndex { const lanceRows: LanceDbRow[] = []; for (const item of cachedItems) { try { - const vector = JSON.parse(item.vector); + const vector = this.parseVector(item.vector); const { uuid, startLine, endLine, contents } = item; lanceRows.push({ diff --git a/gui/src/redux/slices/sessionSlice.ts b/gui/src/redux/slices/sessionSlice.ts index 6cd96dd8e..45d68b456 100644 --- a/gui/src/redux/slices/sessionSlice.ts +++ b/gui/src/redux/slices/sessionSlice.ts @@ -405,7 +405,6 @@ export const sessionSlice = createSlice({ } } else if (message.role === "thinking" && message.signature) { if (lastMessage.role === "thinking") { - console.log("add signature", message.signature); lastMessage.signature = message.signature; } } else if ( From 1b58a968f8e044f421650f800c6f5d7b531bd7ca Mon Sep 17 00:00:00 2001 From: Nate Date: Sat, 5 Jul 2025 09:56:27 -0700 Subject: [PATCH 2/2] more informative log for retrieval tool call parsing failures --- core/context/retrieval/pipelines/BaseRetrievalPipeline.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/context/retrieval/pipelines/BaseRetrievalPipeline.ts b/core/context/retrieval/pipelines/BaseRetrievalPipeline.ts index d13da2145..5089678c1 100644 --- a/core/context/retrieval/pipelines/BaseRetrievalPipeline.ts +++ b/core/context/retrieval/pipelines/BaseRetrievalPipeline.ts @@ -225,9 +225,11 @@ Determine which tools should be used to answer this query. You should feel free .join(""); const parsed = JSON.parse(responseContent); toolCalls = parsed.tools || []; - console.log("retrieveWithTools", toolCalls); } catch (e) { - console.log("Failed to parse tool selection response", e); + console.log( + `Failed to parse tool selection response: ${toolSelectionResponse.content}\n\n`, + e, + ); return []; }