Skip to content

Commit cc669b1

Browse files
committed
fix: address review feedback - schema completeness + timeout cleanup in finally
Reviewer: rwmjhb (CortexReach) 1. Schema completeness: add rerankTimeoutMs to openclaw.plugin.json retrieval schema and index.ts PluginConfig.retrieval 2. Timeout cleanup: move clearTimeout into finally block so timer is always cleared even on fast failure paths 3. Also update warning message to show actual configured timeout value Closes #346
1 parent a01e47e commit cc669b1

File tree

3 files changed

+25
-8
lines changed

3 files changed

+25
-8
lines changed

index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ interface PluginConfig {
120120
rerankApiKey?: string;
121121
rerankModel?: string;
122122
rerankEndpoint?: string;
123+
/** Rerank API timeout in milliseconds (default: 5000). Increase for local/CPU-based rerank servers. */
124+
rerankTimeoutMs?: number;
123125
rerankProvider?:
124126
| "jina"
125127
| "siliconflow"

openclaw.plugin.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,12 @@
319319
"default": "https://api.jina.ai/v1/rerank",
320320
"description": "Reranker API endpoint URL. Compatible with Jina-compatible endpoints and dedicated adapters such as TEI, SiliconFlow, Voyage, Pinecone, and DashScope."
321321
},
322+
"rerankTimeoutMs": {
323+
"type": "integer",
324+
"minimum": 1,
325+
"default": 5000,
326+
"description": "Rerank API timeout in milliseconds (default: 5000). Increase for local/CPU-based rerank servers."
327+
},
322328
"rerankProvider": {
323329
"type": "string",
324330
"enum": [
@@ -1078,6 +1084,12 @@
10781084
"help": "Custom reranker API endpoint URL",
10791085
"advanced": true
10801086
},
1087+
"retrieval.rerankTimeoutMs": {
1088+
"label": "Rerank Timeout (ms)",
1089+
"placeholder": "5000",
1090+
"help": "Rerank API timeout in milliseconds. Increase for local/CPU-based rerank servers.",
1091+
"advanced": true
1092+
},
10811093
"retrieval.rerankProvider": {
10821094
"label": "Reranker Provider",
10831095
"help": "Provider format: jina (default), siliconflow, voyage, pinecone, dashscope, or tei",

src/retriever.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -865,14 +865,17 @@ export class MemoryRetriever {
865865
const controller = new AbortController();
866866
const timeout = setTimeout(() => controller.abort(), this.config.rerankTimeoutMs ?? 5000);
867867

868-
const response = await fetch(endpoint, {
869-
method: "POST",
870-
headers,
871-
body: JSON.stringify(body),
872-
signal: controller.signal,
873-
});
874-
875-
clearTimeout(timeout);
868+
let response: Response;
869+
try {
870+
response = await fetch(endpoint, {
871+
method: "POST",
872+
headers,
873+
body: JSON.stringify(body),
874+
signal: controller.signal,
875+
});
876+
} finally {
877+
clearTimeout(timeout);
878+
}
876879

877880
if (response.ok) {
878881
const data: unknown = await response.json();

0 commit comments

Comments
 (0)