[PR #6489] [MERGED] fix: enforce agent timeout on capability language model calls #7199

Closed
opened 2026-10-23 04:17:27 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/6489
Author: @Promansis
Created: 9/21/2026
Status: ✅ Merged
Merged: 9/21/2026
Merged by: @Promansis

Base: staging ← Head: fix(capability)/ltm-agent-request-timeout


📝 Commits (2)

  • 425bf7b fix: enforce agent timeout on capability language model calls
  • cacf205 Merge branch 'staging' into fix(capability)/ltm-agent-request-timeout

📊 Changes

2 files changed (+30 additions, -10 deletions)

View changed files

📝 packages/server/src/services/capability-packages/capability-language-model.service.ts (+20 -10)
📝 scripts/regressions/capability-package-lifecycle.regression.ts (+10 -0)

📄 Description

Linked issue

Closes https://github.com/Pasta-Devs/Marinara-Engine/issues/6488

Why this change

Long-Term Memory (and any capability package) extraction through an agent connection can fail on large payloads because the LLM transport uses a fixed two-minute inter-chunk body timeout (LLM_BODY_TIMEOUT) instead of the host's configured agent request timeout. A slow-but-progressing provider (e.g. a local model thinking for more than two minutes between chunks) gets cut off at exactly 120 seconds even when AGENT_CALL_TIMEOUT_MS is longer, and there is no total-duration deadline at all.

The fix aligns the capability languageModels.chatComplete host path with the normal agent-call timeout policy (agentCallSignal), which LTM extraction and other capability packages inherit.

What changed

  • packages/server/src/services/capability-packages/capability-language-model.service.ts
    • chatComplete now wraps the provider call in withLlmRequestTimeout(getAgentCallTimeoutMs()) so the transport headers/body budget follows the configured agent timeout instead of the fixed 120s fallback.
    • A composed signal AbortSignal.any([caller signal, AbortSignal.timeout(getAgentCallTimeoutMs())]) is passed to the provider so AGENT_CALL_TIMEOUT_MS is enforced as a total-duration cap while caller cancellation is preserved — matching agent-executor agentCallSignal and the LTM runtime recall path.
  • scripts/regressions/capability-package-lifecycle.regression.ts
    • Adds source-level assertions that capability chatComplete keeps the total-duration deadline wiring and the transport-timeout scope.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Manual verification notes

Completed by maintainer direction (automated checks, not browser click-through):

  • pnpm --filter @marinara-engine/server lint — exit 0 (type-check gate)
  • node ./scripts/run-regressions.mjs --filter capability-package-lifecycle — PASSED (1.1s)
  • prettier --check on both changed files — clean

Summary by CodeRabbit

  • Bug Fixes

    • Language-model requests now stop after the configured timeout, including streaming responses.
    • Caller cancellation is respected alongside the timeout deadline, improving request reliability.
  • Tests

    • Added regression coverage for request timeouts and cancellation behavior.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/6489 **Author:** [@Promansis](https://github.com/Promansis) **Created:** 9/21/2026 **Status:** ✅ Merged **Merged:** 9/21/2026 **Merged by:** [@Promansis](https://github.com/Promansis) **Base:** `staging` ← **Head:** `fix(capability)/ltm-agent-request-timeout` --- ### 📝 Commits (2) - [`425bf7b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/425bf7b82d2b354b200bfa45a3b6acbe2789ea0f) fix: enforce agent timeout on capability language model calls - [`cacf205`](https://github.com/Pasta-Devs/Marinara-Engine/commit/cacf20501b1cde00f70346080e37fc426cb597e7) Merge branch 'staging' into fix(capability)/ltm-agent-request-timeout ### 📊 Changes **2 files changed** (+30 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `packages/server/src/services/capability-packages/capability-language-model.service.ts` (+20 -10) 📝 `scripts/regressions/capability-package-lifecycle.regression.ts` (+10 -0) </details> ### 📄 Description ## Linked issue Closes https://github.com/Pasta-Devs/Marinara-Engine/issues/6488 ## Why this change Long-Term Memory (and any capability package) extraction through an agent connection can fail on large payloads because the LLM transport uses a fixed two-minute inter-chunk body timeout (`LLM_BODY_TIMEOUT`) instead of the host's configured agent request timeout. A slow-but-progressing provider (e.g. a local model thinking for more than two minutes between chunks) gets cut off at exactly 120 seconds even when `AGENT_CALL_TIMEOUT_MS` is longer, and there is no total-duration deadline at all. The fix aligns the capability `languageModels.chatComplete` host path with the normal agent-call timeout policy (`agentCallSignal`), which LTM extraction and other capability packages inherit. ## What changed - `packages/server/src/services/capability-packages/capability-language-model.service.ts` - `chatComplete` now wraps the provider call in `withLlmRequestTimeout(getAgentCallTimeoutMs())` so the transport headers/body budget follows the configured agent timeout instead of the fixed 120s fallback. - A composed signal `AbortSignal.any([caller signal, AbortSignal.timeout(getAgentCallTimeoutMs())])` is passed to the provider so `AGENT_CALL_TIMEOUT_MS` is enforced as a total-duration cap while caller cancellation is preserved — matching `agent-executor` `agentCallSignal` and the LTM runtime recall path. - `scripts/regressions/capability-package-lifecycle.regression.ts` - Adds source-level assertions that capability `chatComplete` keeps the total-duration deadline wiring and the transport-timeout scope. ## Validation - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [x] Read and followed `CONTRIBUTING.md` ### Manual verification notes Completed by maintainer direction (automated checks, not browser click-through): - [x] `pnpm --filter @marinara-engine/server lint` — exit 0 (type-check gate) - [x] `node ./scripts/run-regressions.mjs --filter capability-package-lifecycle` — PASSED (1.1s) - [x] `prettier --check` on both changed files — clean <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Language-model requests now stop after the configured timeout, including streaming responses. * Caller cancellation is respected alongside the timeout deadline, improving request reliability. * **Tests** * Added regression coverage for request timeouts and cancellation behavior. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:17:27 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#7199
No description provided.