Skip to content

fix: add raw provider request timeouts#413

Draft
AjTheSpidey wants to merge 1 commit into
rohitg00:mainfrom
AjTheSpidey:fix/provider-request-timeouts
Draft

fix: add raw provider request timeouts#413
AjTheSpidey wants to merge 1 commit into
rohitg00:mainfrom
AjTheSpidey:fix/provider-request-timeouts

Conversation

@AjTheSpidey
Copy link
Copy Markdown

@AjTheSpidey AjTheSpidey commented May 15, 2026

What changed

  • Add a shared timeout wrapper for raw LLM provider HTTP calls.
  • Use it for MiniMax and OpenRouter/Gemini-compatible provider requests.
  • Document AGENTMEMORY_LLM_TIMEOUT_MS in .env.example.
  • Add focused Vitest coverage for default/configured/invalid timeout values and abort-signal propagation.

Why

MiniMax and OpenRouter use raw fetch calls. Without an abort signal, a stalled provider request can hang until the runtime/network stack gives up. This patch gives those requests the same explicit bounded-failure behavior already used elsewhere in the project.

Validation

Passed locally on Windows:

  • npm.cmd exec -- vitest run test/provider-timeout.test.ts test/minimax-provider.test.ts
  • npm.cmd exec -- tsdown

Not green locally:

  • npm.cmd test has unrelated Windows/environment failures in existing tests, including path separator expectations, missing Python for one integration test, and timing-sensitive tests. I did not change those areas.

Summary by CodeRabbit

  • New Features

    • Added configurable timeout support for LLM provider requests via AGENTMEMORY_LLM_TIMEOUT_MS environment variable (default: 120,000ms).
  • Tests

    • Added comprehensive validation tests for provider timeout behavior.

Review Change Stack

Signed-off-by: AjTheSpidey <aj.gupta0911@gmail.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 15, 2026

@AjTheSpidey 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 May 15, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 12d81df9-167c-440d-811c-b5eee46c8310

📥 Commits

Reviewing files that changed from the base of the PR and between 7530339 and feffb99.

📒 Files selected for processing (5)
  • .env.example
  • src/providers/fetch-timeout.ts
  • src/providers/minimax.ts
  • src/providers/openrouter.ts
  • test/provider-timeout.test.ts

📝 Walkthrough

Walkthrough

This PR adds configurable HTTP timeouts to LLM provider calls. A new fetch-timeout utility enforces AbortSignal-based timeouts driven by the AGENTMEMORY_LLM_TIMEOUT_MS environment variable (default 120 seconds). Minimax and OpenRouter providers now use this wrapper instead of direct fetch calls. Tests validate timeout configuration parsing and verify providers forward the abort signal during requests.

Changes

LLM Provider HTTP Timeout Control

Layer / File(s) Summary
Timeout configuration and fetch wrapper
.env.example, src/providers/fetch-timeout.ts
New getLlmTimeoutMs() reads and validates the AGENTMEMORY_LLM_TIMEOUT_MS env var (default 120,000 ms). fetchWithLlmTimeout() wraps fetch with AbortSignal.timeout() and provides provider-specific error messages on timeout.
Provider fetch integration
src/providers/minimax.ts, src/providers/openrouter.ts
Both providers import and use fetchWithLlmTimeout() in place of direct fetch calls, passing provider name and request details to apply configured timeouts.
Timeout configuration and provider integration tests
test/provider-timeout.test.ts
Tests validate getLlmTimeoutMs() defaults to 120,000, respects positive integer strings, and falls back on invalid values. Integration tests stub fetch to verify both Minimax and OpenRouter providers pass AbortSignal in their HTTP requests.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related issues

  • rohitg00/agentmemory#373: Implements the same solution—a shared fetch-with-timeout helper controlled by AGENTMEMORY_LLM_TIMEOUT_MS with provider integration and tests.

Possibly related PRs

  • rohitg00/agentmemory#103: Introduced the original fetch-based implementation in src/providers/minimax.ts; this PR adds timeout safety to that call.

Poem

🐰 A timeout to guard every fetch,
No hanging requests left to age,
Config-driven, clean, and hale,
Each provider reads the tale,
Milliseconds tame the gale!

🚥 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 directly and clearly summarizes the main change: adding configurable request timeouts for raw LLM provider HTTP calls across MiniMax and OpenRouter providers.
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

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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

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

@AjTheSpidey
Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 15, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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