Skip to content

fix(plugin): wrap auto-recall in withTimeout to prevent indefinite agent hang#688

Merged
qin-ctx merged 1 commit intovolcengine:mainfrom
mvanhorn:osc/673-auto-recall-timeout
Mar 17, 2026
Merged

fix(plugin): wrap auto-recall in withTimeout to prevent indefinite agent hang#688
qin-ctx merged 1 commit intovolcengine:mainfrom
mvanhorn:osc/673-auto-recall-timeout

Conversation

@mvanhorn
Copy link
Contributor

Summary

The before_agent_start hook in the memory plugin calls OpenViking's search API for auto-recall before every agent run. The Promise.allSettled calls and subsequent getClient() calls had no timeout protection. If the HTTP calls hang (during initialization, after gateway restart, or due to transient network issues), the entire agent pipeline blocks indefinitely - no timeout, no error, no fallback.

The file already imports withTimeout from process-manager.ts but never uses it in the recall path. This PR wraps the auto-recall block with withTimeout using a 5-second timeout (AUTO_RECALL_TIMEOUT_MS). On timeout, a warning is logged and the agent starts without memory context instead of hanging forever.

Changes

  • Added AUTO_RECALL_TIMEOUT_MS = 5_000 constant
  • Wrapped the entire auto-recall block (from Promise.allSettled through memory injection) in withTimeout
  • Updated the catch block log message to mention "timed out" for clarity
  • No changes to the happy path - existing recall logic is untouched

Fixes #673

This contribution was developed with AI assistance (Claude Code).

Test plan

  • Start agent with OpenViking server running - auto-recall works as before
  • Stop OpenViking server mid-session - auto-recall times out after 5s, agent starts without memory context, warning logged
  • Verify no regression in auto-capture (separate hook, not affected)

…ent hang

The before_agent_start hook calls OpenViking's search API for auto-recall
before every agent run. The Promise.allSettled calls and subsequent
getClient() calls had no timeout protection - if the HTTP calls hang
(e.g. during initialization or after gateway restart), the entire agent
pipeline blocks indefinitely with no timeout, no error, and no fallback.

This wraps the auto-recall block with the existing withTimeout utility
using a 5-second timeout (AUTO_RECALL_TIMEOUT_MS). On timeout, a warning
is logged and the agent starts without memory context.

Fixes volcengine#673

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@qin-ctx qin-ctx merged commit 6c60a1d into volcengine:main Mar 17, 2026
6 checks passed
@github-project-automation github-project-automation bot moved this from Backlog to Done in OpenViking project Mar 17, 2026
@mvanhorn
Copy link
Contributor Author

Thanks for the quick review and merge, @qin-ctx.

Jah-yee added a commit to Jah-yee/OpenViking that referenced this pull request Mar 18, 2026
Fixes issue volcengine#748 - The auto-recall logic in examples/openclaw-plugin/index.ts
was missing timeout protection, causing the agent to hang indefinitely if
OpenViking HTTP calls hang during transient connection issues.

This fix:
- Imports withTimeout from process-manager.js
- Adds AUTO_RECALL_TIMEOUT_MS constant (5000ms)
- Wraps the entire auto-recall block in withTimeout
- Updates catch block to mention 'timed out' for clarity

This is the same fix that was applied to openclaw-memory-plugin in PR volcengine#688.
Jah-yee pushed a commit to Jah-yee/OpenViking that referenced this pull request Mar 18, 2026
PR volcengine#688 fixed timeout issue in openclaw-memory-plugin but the plugin
was later refactored to openclaw-plugin without carrying over the fix.

This adds:
1. Import withTimeout from process-manager
2. Define autoRecallTimeoutMs constant (5000ms)
3. Wrap entire auto-recall logic in withTimeout to prevent
   indefinite blocking during transient connection issues

Fixes: volcengine#748
Jah-yee added a commit to Jah-yee/OpenViking that referenced this pull request Mar 18, 2026
Apply same fix from PR volcengine#688 to examples/openclaw-plugin/index.ts:
- Add AUTO_RECALL_TIMEOUT_MS constant (5 seconds)
- Wrap auto-recall block with withTimeout to prevent indefinite hangs
- Update error message to mention 'timed out' for clarity

This fixes issue volcengine#748 - if OpenViking HTTP calls hang during
transient connection issues, the before_prompt_build hook now
times out gracefully instead of blocking indefinitely.

Fixes volcengine#748
qin-ctx added a commit that referenced this pull request Mar 19, 2026
PR #662 renamed the plugin directory and rewrote index.ts from a stale
branch base, silently dropping two merged bug fixes:

- #681: share pending clientPromise across dual-context registrations
  to prevent before_agent_start hook from hanging forever
- #688: wrap auto-recall search in withTimeout(5s) to prevent indefinite
  agent hang when OpenViking search API is slow or unresponsive
chenjw pushed a commit that referenced this pull request Mar 19, 2026
…rge (#779)

PR #662 renamed the plugin directory and rewrote index.ts from a stale
branch base, silently dropping two merged bug fixes:

- #681: share pending clientPromise across dual-context registrations
  to prevent before_agent_start hook from hanging forever
- #688: wrap auto-recall search in withTimeout(5s) to prevent indefinite
  agent hang when OpenViking search API is slow or unresponsive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Bug]: memory-openviking plugin before_agent_start auto-recall hangs indefinitely, causing total silent agent failure

2 participants