Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/retriever.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ export interface RetrievalConfig {
rerankModel?: string;
/** Reranker API endpoint (default: https://api.jina.ai/v1/rerank). */
rerankEndpoint?: string;
/** Reranker request timeout in milliseconds (default: 10000). */
rerankTimeoutMs?: number;
/** Reranker provider format. Determines request/response shape and auth header.
* - "jina" (default): Authorization: Bearer, string[] documents, results[].relevance_score
* - "siliconflow": same format as jina (alias, for clarity)
Expand Down Expand Up @@ -858,9 +860,10 @@ export class MemoryRetriever {
results.length,
);

// Timeout: 5 seconds to prevent stalling retrieval pipeline
// Timeout to prevent stalling retrieval pipeline
const RERANK_TIMEOUT_MS = this.config.rerankTimeoutMs ?? 10_000;
const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), 5000);
const timeout = setTimeout(() => controller.abort(), RERANK_TIMEOUT_MS);

const response = await fetch(endpoint, {
method: "POST",
Expand Down