Skip to content

[Bug]: Agent runs terminate at exactly 5 minutes due to undici body/header timeout in @librechat/agents #16195

Description

@Learn-Implement

What happened?

Long-running Agent requests terminate at exactly 5 minutes with:

error: [api/server/controllers/agents/client.js #sendCompletion] Unhandled error type terminated

This occurs despite all of the following:

  • HTTP_REQUEST_TIMEOUT_MS=900000 (15 minutes) set in .env and confirmed present inside the API container via docker-compose exec api printenv HTTP_REQUEST_TIMEOUT_MS.
  • waitForRun timeout in api/server/services/Runs/handle.js patched to 60000 * 15 and confirmed active inside the container via grep.
  • Redis enabled with USE_REDIS=true and USE_REDIS_STREAMS=true, confirmed PONG from redis-cli.

Expected: Agent runs should respect the configured 15-minute timeout and complete normally.

Actual: Agent runs are terminated at exactly 5 minutes. The 5-minute mark matches undici's default bodyTimeout and headersTimeout (300,000 ms).

Precedent: This exact issue was already fixed for MCP connections in PR #9476, where an undici Agent with bodyTimeout: 0 and headersTimeout: 0 was configured to prevent the 5-minute cutoff. This report requests the same fix be applied to the OpenAI/DeepSeek client used by the Agent controller.

Presets are less affected than Agents under identical long-running queries, suggesting the Agent networking path is the source of the cutoff.

Version Information

LibreChat v0.8.7
Deployment: Self-hosted Docker Compose (local)
Image: registry.librechat.ai/danny-avila/librechat-dev:latest
Reverse proxy: None (direct port 3080)
Custom endpoints: DeepSeek V4 Pro, Gemini, Qwen
Redis: redis:7-alpine (docker), USE_REDIS_STREAMS=true

Steps to Reproduce

  1. Configure an Agent using the DeepSeek endpoint (deepseek-v4-pro) with reasoning_effort: high.

  2. Set HTTP_REQUEST_TIMEOUT_MS=900000 in .env and pass it to the api service in docker-compose.override.yml.

  3. Patch api/server/services/Runs/handle.js: change timeout = 60000 * 3 to timeout = 60000 * 15 and mount it via docker-compose.override.yml. Confirm inside the container with:
    docker-compose exec api grep -n "timeout = 60000" /app/api/server/services/Runs/handle.js

  4. Enable Redis with USE_REDIS=true and USE_REDIS_STREAMS=true.

  5. Send a complex query that requires more than 5 minutes of high-effort reasoning.

  6. Observe the API logs. At exactly 5 minutes, the request terminates with:
    error: [api/server/controllers/agents/client.js #sendCompletion] Unhandled error type terminated

What browsers are you seeing the problem on?

Microsoft Edge, Firefox, Chrome

Relevant log output

2026-09-13 17:40:34 error: [api/server/controllers/agents/client.js #sendCompletion] Unhandled error type terminated
2026-09-13 17:44:51 error: [api/server/controllers/agents/client.js #sendCompletion] Unhandled error type terminated

Screenshots

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    🐛 bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions