Skip to content

fix: increase systemic timeouts for summarization and consolidation#213

Open
xuli500177 wants to merge 3 commits intorohitg00:mainfrom
xuli500177:fix/increase-systemic-timeouts
Open

fix: increase systemic timeouts for summarization and consolidation#213
xuli500177 wants to merge 3 commits intorohitg00:mainfrom
xuli500177:fix/increase-systemic-timeouts

Conversation

@xuli500177
Copy link
Copy Markdown

@xuli500177 xuli500177 commented Apr 29, 2026

Summary

This PR addresses systemic timeout issues encountered during long coding sessions (e.g., sessions with 300+ observations).

Changes:

  1. Increased Default SDK Timeout: Updated registerWorker in src/index.ts to use a 180s invocationTimeoutMs instead of the 30s default. This provides sufficient head-room for heavy LLM summarization and consolidation tasks.
  2. Increased Hook Script Timeouts:
    • src/hooks/stop.ts: Increased fetch timeout for /agentmemory/summarize to 120s.
    • src/hooks/session-end.ts: Increased timeouts for session end (30s), crystallization (60s), and consolidation pipeline (120s).

Context:

In high-volume sessions, the mem::summarize and mem::consolidate-pipeline functions often require more than 30s of LLM execution time. Without these adjustments, the hooks fail and the memory system misses critical summary/consolidation steps.

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Increased timeout durations for session management, memory consolidation, and summarization operations.
    • Increased worker invocation timeout to 3 minutes.

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 29, 2026

@xuli500177 is attempting to deploy a commit to the rohitg00's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 29, 2026

📝 Walkthrough

Walkthrough

The pull request increases timeout values across the application's hooks and worker configuration. Fetch call AbortSignal timeouts in session-end and stop hooks are extended (ranging from 30s to 120s), and the SDK worker invocation timeout is set to 180 seconds. Trailing newlines are also removed from two hook files.

Changes

Cohort / File(s) Summary
Hook Timeout Increases
src/hooks/session-end.ts, src/hooks/stop.ts
Extended AbortSignal timeouts: session-end fetch calls increased to 30s, 60s, and 120s; stop summarize call increased to 120s.
SDK Configuration
src/index.ts
Added invocationTimeoutMs: 180000 (3 minutes) to worker registration configuration.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Poem

🐰 A rabbit's ode to patience...

Once timeouts were quite swift and brief,
But ops need more time for relief,
Thirty seconds, then sixty, then more—
One-twenty and one-eighty in store!
⏳✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically summarizes the main change: increasing timeouts for summarization and consolidation operations across multiple files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 7/8 reviews remaining, refill in 7 minutes and 30 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/index.ts (1)

107-163: ⚠️ Potential issue | 🟡 Minor

Update the timeout rationale comment to match the new 180s config.

The comment still says 30s, but Line 163 is now 180000ms. Keeping these aligned avoids troubleshooting confusion.

📝 Suggested comment fix
-// projects) `state::set` can occasionally exceed the SDK's 30s timeout.
+// projects) `state::set` can occasionally exceed the SDK's timeout.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/index.ts` around lines 107 - 163, The top-level safety-net comment above
process.on("unhandledRejection") is stale (mentions the SDK's 30s timeout) while
invocationTimeoutMs is now set to 180000 (180s) in the registerWorker call;
update that comment to reference 180s (or "180s / 180000ms") so the rationale
matches the new invocationTimeoutMs value in main and avoids confusion when
reading the registerWorker invocationTimeoutMs setting.
src/hooks/session-end.ts (1)

40-71: ⚠️ Potential issue | 🟡 Minor

Remove inline “increased from …” comments on timeout lines.

These comments are “WHAT” comments and will drift. Prefer named timeout constants instead.

♻️ Suggested cleanup
+const SESSION_END_TIMEOUT_MS = 30_000;
+const CRYSTALS_AUTO_TIMEOUT_MS = 60_000;
+const CONSOLIDATE_PIPELINE_TIMEOUT_MS = 120_000;
+const CLAUDE_BRIDGE_SYNC_TIMEOUT_MS = 30_000;

   try {
     await fetch(`${REST_URL}/agentmemory/session/end`, {
@@
-      signal: AbortSignal.timeout(30000), // Increased from 5s
+      signal: AbortSignal.timeout(SESSION_END_TIMEOUT_MS),
     });
@@
-        signal: AbortSignal.timeout(60000), // Increased from 15s
+        signal: AbortSignal.timeout(CRYSTALS_AUTO_TIMEOUT_MS),
       });
@@
-        signal: AbortSignal.timeout(120000), // Increased from 30s
+        signal: AbortSignal.timeout(CONSOLIDATE_PIPELINE_TIMEOUT_MS),
       });
@@
-        signal: AbortSignal.timeout(30000), // Increased from 5s
+        signal: AbortSignal.timeout(CLAUDE_BRIDGE_SYNC_TIMEOUT_MS),
       });

As per coding guidelines, "Avoid code comments explaining WHAT — use clear naming instead."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/hooks/session-end.ts` around lines 40 - 71, Replace the inline “Increased
from …” comments and magic numeric timeouts with named constants and use those
constants in the AbortSignal.timeout calls; for example, add clearly named
constants (e.g., TIMEOUT_SHORT_MS = 5000, TIMEOUT_MEDIUM_MS = 30000,
TIMEOUT_CONSOLIDATE_MS = 120000) near the top of the module (or import from a
shared timeouts/constants module) and then update the three
AbortSignal.timeout(...) calls in the session-end.ts fetch blocks (the first
generic fetch, the ${REST_URL}/agentmemory/crystals/auto call, the
${REST_URL}/agentmemory/consolidate-pipeline call, and the
${REST_URL}/agentmemory/claude-bridge/sync call) to use those constants and
remove the inline “increased from …” comments.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/hooks/stop.ts`:
- Line 47: Remove the inline change-history comment and replace the magic number
passed to AbortSignal.timeout with a named constant (e.g., STOP_TIMEOUT_MS or
STOP_SIGNAL_TIMEOUT) declared near the top of the module; update the call site
from AbortSignal.timeout(120000) to AbortSignal.timeout(STOP_TIMEOUT_MS) so the
timeout value is self-documenting and the comment is no longer needed.

---

Outside diff comments:
In `@src/hooks/session-end.ts`:
- Around line 40-71: Replace the inline “Increased from …” comments and magic
numeric timeouts with named constants and use those constants in the
AbortSignal.timeout calls; for example, add clearly named constants (e.g.,
TIMEOUT_SHORT_MS = 5000, TIMEOUT_MEDIUM_MS = 30000, TIMEOUT_CONSOLIDATE_MS =
120000) near the top of the module (or import from a shared timeouts/constants
module) and then update the three AbortSignal.timeout(...) calls in the
session-end.ts fetch blocks (the first generic fetch, the
${REST_URL}/agentmemory/crystals/auto call, the
${REST_URL}/agentmemory/consolidate-pipeline call, and the
${REST_URL}/agentmemory/claude-bridge/sync call) to use those constants and
remove the inline “increased from …” comments.

In `@src/index.ts`:
- Around line 107-163: The top-level safety-net comment above
process.on("unhandledRejection") is stale (mentions the SDK's 30s timeout) while
invocationTimeoutMs is now set to 180000 (180s) in the registerWorker call;
update that comment to reference 180s (or "180s / 180000ms") so the rationale
matches the new invocationTimeoutMs value in main and avoids confusion when
reading the registerWorker invocationTimeoutMs setting.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5b615624-faee-4b22-8d5a-51d21c0b491f

📥 Commits

Reviewing files that changed from the base of the PR and between 1a8c0f3 and 655c374.

📒 Files selected for processing (3)
  • src/hooks/session-end.ts
  • src/hooks/stop.ts
  • src/index.ts

Comment thread src/hooks/stop.ts
headers: authHeaders(),
body: JSON.stringify({ sessionId }),
signal: AbortSignal.timeout(30000),
signal: AbortSignal.timeout(120000), // Increased from 30s to 120s
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Drop the inline change-history comment on this timeout line.

Use a named constant if you want the value to be self-documenting.

As per coding guidelines, "Avoid code comments explaining WHAT — use clear naming instead."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/hooks/stop.ts` at line 47, Remove the inline change-history comment and
replace the magic number passed to AbortSignal.timeout with a named constant
(e.g., STOP_TIMEOUT_MS or STOP_SIGNAL_TIMEOUT) declared near the top of the
module; update the call site from AbortSignal.timeout(120000) to
AbortSignal.timeout(STOP_TIMEOUT_MS) so the timeout value is self-documenting
and the comment is no longer needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant