openclaw: a hook that arrives while lazy initialization is in progress gets no client (recall silently skipped)

Aperta Adatta ai principianti
#7,023 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
79/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
typescript
Ambito
ai, backend

Direzione di ricerca

Inizia da hindsight-integrations/openclaw/src/index.ts, in particolare da lazyReinit() e waitForReady() in prossimità delle righe citate; segui il comportamento delle chiamate concorrenti mentre l’inizializzazione è in corso. L’issue suggerisce di aggiungere un test unitario che chiami waitForReady() due volte con un controllo dello stato ritardato di 100 ms. Il lavoro è completato quando entrambe le chiamate si risolvono con un client e gli hook concorrenti di recall e retain non proseguono più senza un client.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

integration:openclaw
Bug Description

When OpenClaw loads a fresh copy of the plugin that never receives service.start() (the registry-reload case from #4828), the first hook calls waitForReady(), which starts lazyReinit(). A second hook that calls waitForReady() while that re-initialization is still running returns at once, because lazyReinit() exits early on isReinitInProgress (and also inside the 30 s cooldown). waitForReady() then resolves with client still null:

// index.ts, lazyReinit()
if (now - lastReinitAttempt < REINIT_COOLDOWN_MS || isReinitInProgress) {
  return;            // a concurrent caller returns before the in-flight init finishes
}

The caller then has no client:

  • before_prompt_build: getClientForContext() returns null and the turn is answered without memories, with only a debug line (Client not initialized, skipping auto-recall).
  • agent_end: on 1.2.0 the turn was dropped (client not initialized, skipping retain). Since #6196 it is queued, which is fine, but it waits for the next queue flush although the client becomes available a few hundred milliseconds later.

We hit this when two sessions finished a turn 69 ms apart, right after OpenClaw had loaded a new plugin copy. The first retain succeeded 250 ms later; the second was dropped (1.2.0).

Steps to Reproduce
  1. External API mode. Make OpenClaw load a new plugin copy without starting its service (a registry reload; on 2026.10/2026.11 this happens routinely: plugin entry invoked without service.start invoked).
  2. Fire two hooks (two agent_end, or a before_prompt_build in another session) within the time the health check and bank-default setup take (a few hundred ms).
  3. The first logs waitForReady called before service.start() — attempting lazy initialization fallback and works; the second gets no client.

As a unit test: call global.__hindsightClient.waitForReady() twice without awaiting the first, with a health-check mock that resolves after 100 ms, and check getClient() after the second call resolves.

Expected Behavior

Concurrent callers await the same in-flight initialization (keep the pending promise and return it), so every hook that arrives during lazy init gets the client once it exists. The cooldown should only stop a new attempt after a failed one, not make callers skip a successful one that is still running.

Actual Behavior

Only the caller that started the re-initialization gets a client. The others return immediately with client === null.

Version
  • @vectorize-io/hindsight-openclaw 1.2.0 when observed; the early return is unchanged in 1.2.3 (= main at c828c7e). On 1.2.3 a concurrent retain is queued instead of dropped (#6196), a concurrent recall is still skipped.
  • Hindsight API 1.3.0, OpenClaw 2026.11.8
LLM Provider

Not relevant.

Suspected code location

hindsight-integrations/openclaw/src/index.ts: lazyReinit() (lines 622-680) and waitForReady() in the __hindsightClient global (lines 687-716), called from the before_prompt_build handler (line 2954) and the agent_end handler (line 3384). Storing the in-flight lazyReinit promise and awaiting it from waitForReady() would fix both hooks.

TypeScript-only (OpenClaw plugin lifecycle).

Lingua principale
Python
Stelle
45.2k
Fork
5.9k
Merge medio
5h 46m
PR unite (30g)
389

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di vectorize-io/hindsight

Tutte le issue di vectorize-io/hindsight

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.