[PR #6581] [MERGED] feat(decision): per-connection time limit, and a Test that reports the real time #7234

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/6581
Author: @kolacheee
Created: 9/23/2026
Status: ✅ Merged
Merged: 9/23/2026
Merged by: @kolacheee

Base: staging ← Head: feat/decision-time-limit


📝 Commits (3)

  • c1b0001 feat(decision): per-connection time limit, and a Test that reports the real time
  • cdf0266 fix(decision): wait past a long time limit in Test, and format-proof the regression
  • 20b959b fix(decision): export the edited Decision fields, and keep a blank imported limit as the default

📊 Changes

20 files changed (+481 additions, -39 deletions)

View changed files

📝 CHANGELOG.md (+2 -0)
📝 docs/agents/custom-agents.md (+1 -1)
📝 docs/connections/decision-models.md (+5 -2)
📝 docs/prompts/conditional-prompts.md (+1 -1)
➕ e2e/decision-time-limit.e2e.ts (+89 -0)
📝 packages/client/src/components/connections/ConnectionEditor.tsx (+54 -14)
📝 packages/client/src/components/connections/DecisionDefaultControl.tsx (+2 -13)
📝 packages/client/src/hooks/use-connections.ts (+1 -0)
📝 packages/client/src/lib/connection-transfer.ts (+13 -0)
➕ packages/client/src/lib/decision-test-message.ts (+31 -0)
📝 packages/client/src/localization/locales/en.json (+5 -1)
📝 packages/server/src/db/schema/connections.ts (+2 -0)
📝 packages/server/src/routes/connections.routes.ts (+8 -0)
📝 packages/server/src/services/decision/decision-connection.ts (+9 -1)
📝 packages/server/src/services/decision/decision-default.ts (+2 -2)
📝 packages/server/src/services/storage/connections.storage.ts (+3 -0)
📝 packages/shared/src/schemas/connection.schema.ts (+9 -0)
📝 packages/shared/src/types/connection.ts (+6 -0)
📝 packages/shared/src/types/decision.ts (+29 -4)
➕ scripts/regressions/decision-connection-time-limit.regression.ts (+209 -0)

📄 Description

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.
Outside and first-time contributors also require an approving review from SpicyMarinara.

Linked issue

Closes #6580

Why this change

  • A beta tester's TypeSafe Decision connection worked only some of the time. Their server log showed the request cut off exactly 1,500 ms after it went out. Every Decision connection had a fixed 1.5 second limit, during chats and in Test, with no way to change it.
  • TypeSafe's response time varies more than that allows. In 13 requests rejected before any model ran, most answered in 0.27 to 0.38 s, but 4 took 1.4 to 2.6 s. With Jev's own time added, real requests land on both sides of 1.5 s.
  • Test could not tell a slow answer from a dead endpoint. It used the same 1.5 s limit and reported only "did not answer within the time limit".

What changed

  • A per-connection Time limit. Each Decision connection has a Time limit (seconds) field under Recent-message token budget: 0.5 to 30 seconds, 1.5 by default. The help text explains the trade-off: a statement asked before the reply can hold up the reply for this long.
    • It is stored as a new nullable decision_timeout_ms column. Null means the default, so existing connections keep 1.5 s and would follow the default if it ever changes. No storage-format bump, the same as the other Decision columns.
    • Chats use it for activation questions, decision statements, lorebook decisions and Smart order, all through the Decision backend.
    • It survives duplicating a connection and connection export/import, and imported values are clamped to the range.
  • Test reports the real time. It waits at least 10 seconds, and 5 seconds past a longer limit, and shows how long the answer took next to the connection's limit. An answer slower than the limit shows as failed, and the message says that during chats it would count as no answer and suggests testing a few times. A Test that gets no answer at all says how long it waited. The Decision model dropdown's Test shows the same message.
  • Docs: the Decision Models guide covers the field in Set up a Decision connection, Time limits and Troubleshooting. The agent and conditional prompt guides no longer say the budget is a fixed 1.5 s. A stale code comment that called 1.5 s "generous" is corrected.
  • Local models and the installed decision model keep their own fixed limits. This change is for Decision connections only.

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

Run by the agent:

  • pnpm check, pnpm localization:check and pnpm regression:node (363 of 363 on the first commit; the five decision regressions again after the review fix) on the branch.
  • New scripts/regressions/decision-connection-time-limit.regression.ts, against a fake System One server that answers after a set delay:
    • The limit's default, clamping and schema range.
    • Chats: the same 1 s answer is lost at a 0.5 s limit and kept at 2 s.
    • The Test route waits past the limit and returns the real time, the limit, and how long it waited; a limit above 10 s extends the wait.
    • Create, update, duplicate, clearing back to the default, and export/import (including clamping and non-Decision connections).
    • The Test message for within the limit, over it, and no answer at all.
    • Each wiring point was mutation-checked: reverting it makes the regression fail.
  • New e2e/decision-time-limit.e2e.ts, passing locally on desktop-chromium and mobile-chromium (mobile-webkit cannot launch on the agent's machine, so CI covers it). It sets the limit to 0.5 s, gets the over-the-limit message from a 1 s answer, checks the value was saved, sets 2.5 s, gets the normal result, and checks the value survives a reload. The existing Decision settings e2e still passes.
  • Local CodeRabbit review: 2 findings, both fixed. Test waited exactly the limit when it was 10 s or more, so an answer just past a long limit came back as no answer; it now waits 5 s past a longer limit. The regression's formatted-number checks assumed a period as the decimal separator (a German-locale run formats 1.84 as "1,84"); they now use the same formatter as the message. The fix commit reviewed clean.

Please verify manually:

  • Open a Decision connection, set Time limit to 0.5, click Test Connection, and confirm the result shows the real time and says the answer was over the limit (a hosted provider is usually slower than 0.5 s).
  • Set it back to 1.5 or higher, test again, and confirm the result shows the probability, the time and the limit.
  • With a TypeSafe connection, click Test several times and confirm the times you see match what the limit needs.
  • Export the connection, import it, and confirm the time limit came along.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

Changed user docs for the batched [docs-i18n] follow-up (#6532): docs/connections/decision-models.md (one new paragraph, two new list items, one changed step), docs/agents/custom-agents.md (one sentence), docs/prompts/conditional-prompts.md (one sentence).

UI evidence (if applicable)

The new e2e attaches two screenshots to its report: the Time limit field under the token budget, and the Test result for an answer over the limit ("Answered in 1.03 s, over this connection's 0.5 s time limit, so during chats this answer would count as no...").

Summary by CodeRabbit

  • New Features

    • Set a configurable time limit for Decision connections, from 0.5 to 30 seconds; the default remains 1.5 seconds.
    • Connection tests show the answer time and configured limit, and wait longer to report slow answers. Answers exceeding the limit are identified as too slow and won’t count during chats.
    • Time limits are preserved when connections are duplicated or transferred.
  • Documentation

    • Updated setup, activation-question, and troubleshooting guidance to explain configurable Decision connection limits.

🔄 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/6581 **Author:** [@kolacheee](https://github.com/kolacheee) **Created:** 9/23/2026 **Status:** ✅ Merged **Merged:** 9/23/2026 **Merged by:** [@kolacheee](https://github.com/kolacheee) **Base:** `staging` ← **Head:** `feat/decision-time-limit` --- ### 📝 Commits (3) - [`c1b0001`](https://github.com/Pasta-Devs/Marinara-Engine/commit/c1b00017aa1486288e181f0068b37fa20ddd5b5b) feat(decision): per-connection time limit, and a Test that reports the real time - [`cdf0266`](https://github.com/Pasta-Devs/Marinara-Engine/commit/cdf02664a529576284ce471ee7d450fd0a3886ae) fix(decision): wait past a long time limit in Test, and format-proof the regression - [`20b959b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/20b959b76f03f7ce3fc3f5a37d024d45f93ee419) fix(decision): export the edited Decision fields, and keep a blank imported limit as the default ### 📊 Changes **20 files changed** (+481 additions, -39 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+2 -0) 📝 `docs/agents/custom-agents.md` (+1 -1) 📝 `docs/connections/decision-models.md` (+5 -2) 📝 `docs/prompts/conditional-prompts.md` (+1 -1) ➕ `e2e/decision-time-limit.e2e.ts` (+89 -0) 📝 `packages/client/src/components/connections/ConnectionEditor.tsx` (+54 -14) 📝 `packages/client/src/components/connections/DecisionDefaultControl.tsx` (+2 -13) 📝 `packages/client/src/hooks/use-connections.ts` (+1 -0) 📝 `packages/client/src/lib/connection-transfer.ts` (+13 -0) ➕ `packages/client/src/lib/decision-test-message.ts` (+31 -0) 📝 `packages/client/src/localization/locales/en.json` (+5 -1) 📝 `packages/server/src/db/schema/connections.ts` (+2 -0) 📝 `packages/server/src/routes/connections.routes.ts` (+8 -0) 📝 `packages/server/src/services/decision/decision-connection.ts` (+9 -1) 📝 `packages/server/src/services/decision/decision-default.ts` (+2 -2) 📝 `packages/server/src/services/storage/connections.storage.ts` (+3 -0) 📝 `packages/shared/src/schemas/connection.schema.ts` (+9 -0) 📝 `packages/shared/src/types/connection.ts` (+6 -0) 📝 `packages/shared/src/types/decision.ts` (+29 -4) ➕ `scripts/regressions/decision-connection-time-limit.regression.ts` (+209 -0) </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. > Outside and first-time contributors also require an approving review from `SpicyMarinara`. <!-- See CONTRIBUTING.md § Branches. --> ## Linked issue Closes #6580 ## Why this change - **A beta tester's TypeSafe Decision connection worked only some of the time.** Their server log showed the request cut off exactly 1,500 ms after it went out. Every Decision connection had a fixed 1.5 second limit, during chats and in **Test**, with no way to change it. - **TypeSafe's response time varies more than that allows.** In 13 requests rejected before any model ran, most answered in 0.27 to 0.38 s, but 4 took 1.4 to 2.6 s. With Jev's own time added, real requests land on both sides of 1.5 s. - **Test could not tell a slow answer from a dead endpoint.** It used the same 1.5 s limit and reported only "did not answer within the time limit". ## What changed - **A per-connection Time limit.** Each Decision connection has a **Time limit (seconds)** field under **Recent-message token budget**: 0.5 to 30 seconds, 1.5 by default. The help text explains the trade-off: a statement asked before the reply can hold up the reply for this long. - It is stored as a new nullable `decision_timeout_ms` column. Null means the default, so existing connections keep 1.5 s and would follow the default if it ever changes. No storage-format bump, the same as the other Decision columns. - Chats use it for activation questions, decision statements, lorebook decisions and Smart order, all through the Decision backend. - It survives duplicating a connection and connection export/import, and imported values are clamped to the range. - **Test reports the real time.** It waits at least 10 seconds, and 5 seconds past a longer limit, and shows how long the answer took next to the connection's limit. An answer slower than the limit shows as failed, and the message says that during chats it would count as no answer and suggests testing a few times. A Test that gets no answer at all says how long it waited. The Decision model dropdown's **Test** shows the same message. - **Docs:** the Decision Models guide covers the field in **Set up a Decision connection**, **Time limits** and **Troubleshooting**. The agent and conditional prompt guides no longer say the budget is a fixed 1.5 s. A stale code comment that called 1.5 s "generous" is corrected. - Local models and the installed decision model keep their own fixed limits. This change is for Decision connections only. ## 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 Run by the agent: - `pnpm check`, `pnpm localization:check` and `pnpm regression:node` (363 of 363 on the first commit; the five decision regressions again after the review fix) on the branch. - New `scripts/regressions/decision-connection-time-limit.regression.ts`, against a fake System One server that answers after a set delay: - The limit's default, clamping and schema range. - Chats: the same 1 s answer is lost at a 0.5 s limit and kept at 2 s. - The Test route waits past the limit and returns the real time, the limit, and how long it waited; a limit above 10 s extends the wait. - Create, update, duplicate, clearing back to the default, and export/import (including clamping and non-Decision connections). - The Test message for within the limit, over it, and no answer at all. - Each wiring point was mutation-checked: reverting it makes the regression fail. - New `e2e/decision-time-limit.e2e.ts`, passing locally on desktop-chromium and mobile-chromium (mobile-webkit cannot launch on the agent's machine, so CI covers it). It sets the limit to 0.5 s, gets the over-the-limit message from a 1 s answer, checks the value was saved, sets 2.5 s, gets the normal result, and checks the value survives a reload. The existing Decision settings e2e still passes. - Local CodeRabbit review: 2 findings, both fixed. Test waited exactly the limit when it was 10 s or more, so an answer just past a long limit came back as no answer; it now waits 5 s past a longer limit. The regression's formatted-number checks assumed a period as the decimal separator (a German-locale run formats 1.84 as "1,84"); they now use the same formatter as the message. The fix commit reviewed clean. Please verify manually: - Open a Decision connection, set **Time limit** to 0.5, click **Test Connection**, and confirm the result shows the real time and says the answer was over the limit (a hosted provider is usually slower than 0.5 s). - Set it back to 1.5 or higher, test again, and confirm the result shows the probability, the time and the limit. - With a TypeSafe connection, click **Test** several times and confirm the times you see match what the limit needs. - Export the connection, import it, and confirm the time limit came along. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) Changed user docs for the batched `[docs-i18n]` follow-up (#6532): `docs/connections/decision-models.md` (one new paragraph, two new list items, one changed step), `docs/agents/custom-agents.md` (one sentence), `docs/prompts/conditional-prompts.md` (one sentence). ## UI evidence (if applicable) The new e2e attaches two screenshots to its report: the **Time limit** field under the token budget, and the Test result for an answer over the limit ("Answered in 1.03 s, over this connection's 0.5 s time limit, so during chats this answer would count as no..."). <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Set a configurable time limit for Decision connections, from 0.5 to 30 seconds; the default remains 1.5 seconds. * Connection tests show the answer time and configured limit, and wait longer to report slow answers. Answers exceeding the limit are identified as too slow and won’t count during chats. * Time limits are preserved when connections are duplicated or transferred. * **Documentation** * Updated setup, activation-question, and troubleshooting guidance to explain configurable Decision connection limits. <!-- 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:47 +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#7234
No description provided.