@@ -227,13 +227,13 @@ export default definePluginEntry({
227227 try {
228228 recall = await runWithTimeout ( {
229229 timeoutMs : DEFAULT_TOOL_RECALL_TIMEOUT_MS ,
230- task : async ( ) => {
230+ task : async ( deadlineAtMs ) => {
231231 let vector : number [ ] ;
232232 try {
233233 vector = await embeddings . embed (
234234 agentId ,
235235 normalizeRecallQuery ( query , currentCfg . recallMaxChars ) ,
236- { timeoutMs : DEFAULT_TOOL_RECALL_TIMEOUT_MS } ,
236+ { timeoutMs : Math . max ( 1 , deadlineAtMs - Date . now ( ) ) } ,
237237 ) ;
238238 } catch ( error ) {
239239 throw new MemoryRecallEmbeddingError ( error ) ;
@@ -244,6 +244,7 @@ export default definePluginEntry({
244244 vector ,
245245 limit + DEFAULT_TOOL_RECALL_OVERFETCH_EXTRA ,
246246 0.1 ,
247+ { timeoutMs : Math . max ( 0 , deadlineAtMs - Date . now ( ) ) } ,
247248 ) ;
248249 } ,
249250 } ) ;
@@ -535,11 +536,11 @@ export default definePluginEntry({
535536 let recallPhase : "embedding" | "search" = "embedding" ;
536537 const recall = await runWithTimeout ( {
537538 timeoutMs : DEFAULT_AUTO_RECALL_TIMEOUT_MS ,
538- task : async ( ) => {
539+ task : async ( deadlineAtMs ) => {
539540 let vector : number [ ] ;
540541 try {
541542 vector = await embeddings . embed ( agentId , recallQuery , {
542- timeoutMs : DEFAULT_AUTO_RECALL_TIMEOUT_MS ,
543+ timeoutMs : Math . max ( 1 , deadlineAtMs - Date . now ( ) ) ,
543544 } ) ;
544545 } catch ( error ) {
545546 throw new MemoryRecallEmbeddingError ( error ) ;
@@ -549,7 +550,9 @@ export default definePluginEntry({
549550 recallPhase = "search" ;
550551 // Overfetch to compensate for sludge filtering: if contaminated
551552 // entries occupy the top slots we still surface enough clean ones.
552- return await db . search ( agentId , vector , DEFAULT_AUTO_RECALL_OVERFETCH_LIMIT , 0.3 ) ;
553+ return await db . search ( agentId , vector , DEFAULT_AUTO_RECALL_OVERFETCH_LIMIT , 0.3 , {
554+ timeoutMs : Math . max ( 0 , deadlineAtMs - Date . now ( ) ) ,
555+ } ) ;
553556 } ,
554557 } ) ;
555558 if ( recall . status === "timeout" ) {
0 commit comments