[PR #6531] [MERGED] feat(agents): add semantic activation questions #7215

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

📋 Pull Request Information

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

Base: staging ← Head: codex/agent-activation-questions


📝 Commits (6)

  • 61067ce feat(agents): define activation question settings
  • 84285ff feat(agents): gate custom agents with System One decisions
  • 92e8f80 fix(agents): retain decision context speaker identity
  • 0b46f3d Merge remote-tracking branch 'origin/staging' into codex/agent-activation-questions
  • 82cd9ea fix(ui): group activation questions with keywords
  • c838386 fix(ui): match question controls to keyword styling

📊 Changes

36 files changed (+1945 additions, -53 deletions)

View changed files

📝 CHANGELOG.md (+2 -0)
📝 docs/agents/custom-agents.md (+31 -2)
➕ e2e/agent-activation-questions.e2e.ts (+369 -0)
➕ packages/client/src/components/agents/ActivationQuestionFields.tsx (+105 -0)
📝 packages/client/src/components/agents/AgentEditor.tsx (+59 -2)
📝 packages/client/src/components/chat/StoryboardChatSettingsPanel.tsx (+2 -1)
📝 packages/client/src/components/chat/SummaryPopover.tsx (+2 -1)
📝 packages/client/src/components/connections/ConnectionEditor.tsx (+190 -10)
➕ packages/client/src/components/connections/DecisionDefaultControl.tsx (+109 -0)
📝 packages/client/src/components/modals/CreateConnectionModal.tsx (+2 -2)
📝 packages/client/src/components/panels/ConnectionsPanel.tsx (+8 -2)
📝 packages/client/src/components/panels/settings/TTSConfigCard.tsx (+2 -1)
📝 packages/client/src/hooks/use-connections.ts (+21 -1)
📝 packages/client/src/lib/connection-filters.ts (+2 -1)
📝 packages/client/src/lib/connection-transfer.ts (+26 -0)
📝 packages/client/src/localization/locales/en.json (+54 -1)
📝 packages/server/src/db/schema/connections.ts (+4 -0)
📝 packages/server/src/routes/backup.routes.ts (+2 -0)
📝 packages/server/src/routes/connections.routes.ts (+33 -1)
📝 packages/server/src/routes/conversation.routes.ts (+1 -1)

...and 16 more files

📄 Description

Linked issue

Closes #6530

Why this change

Keyword-only activation misses paraphrases and scene changes. Custom agents can now ask a short yes/no question before running, such as “Did the location change?”, and run only when the returned probability meets their threshold. Existing keywords and cadence are checked first. Unavailable, late, or invalid decisions leave eligible agents enabled.

What changed

  • Add a dedicated Decision connection for TypeSafe, OpenRouter, and custom System One endpoints, with an independent Decision model default and a fixed-sample Test action.
  • Resolve linked keys at request time, enforce provider and origin compatibility, preserve key rotation, warn before deleting a borrowed key, and require relinking after standalone imports.
  • Batch custom-agent questions by scan depth before generation and after the completed reply. Resolve agent macros, preserve recent messages within an estimated token budget, support a question-only maximum-skip override, and bound requests/cancellation including stalled DNS validation.
  • Add localized controls, setup/privacy guidance, and a mobile-accessible Save label in the agent editor. Question and its threshold/skip settings share the Activation Keywords card, using the same typography, colors, spacing, and input styling as Keywords and Scan Depth.

This is the first System One implementation. Existing local chat-model decisions and managed Open-Jev installation remain separate phases. No storage-format or app-version change. The branch includes staging commit 89d2a9bb9 (memory correction/recovery fixes from #6527).

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

Recorded automated evidence

  • pnpm check passed on implementation head 0b46f3dad after merging current staging, including localization, formatting, TypeScript, and production builds. One pre-existing GameNarration hook-dependency warning remains.

  • pnpm regression:node: 349/349 passed again on implementation head 0b46f3dad, including the newly merged memory regressions, stalled-DNS timeout and cancellation. pnpm regression:prompt and pnpm check:e2e-types passed on that head.

  • Focused pnpm smoke:ui across desktop Chromium, mobile Chromium, and mobile WebKit: 20 passed, 4 existing desktop-only cases skipped on implementation head 0b46f3dad. All nine new feature cases passed, together with the newly merged scene-recovery flow in all three browsers. Coverage includes saving/reloading questions, disabling/re-enabling defaults, 422 errors, OpenRouter key linking/deletion, and real generation routing against local mock providers.

  • The implementation at 84285ff2b built as a Podman production image and its /api/health returned status: ok. The later speaker-metadata fix and staging merge are covered by the final local build and regression checks.

  • Latest UI validation at c838386e1: pnpm check and pnpm check:e2e-types passed; the existing Decision settings browser test passed on desktop Chromium, mobile Chromium, and mobile WebKit (3/3). Visually checked the shared card and matched Question/Keywords styles in desktop light/dark and mobile screenshots. Focused local CodeRabbit review completed with zero findings.

Claim boundaries

Risk Evidence
Agent routing Real generation requests prove below-threshold skipping, above-threshold runs, fail-open on HTTP failure, completed-reply context, single-speaker group-chat attribution and macro expansion, no decision call for a keyword miss, and unchanged agents without questions. Saved successful runs are checked.
Credentials/outbound requests Regression covers rotating/deleted keys, wrong-origin links, quarantine, no copied linked key, redirect rejection, bounded responses, timeout, and cancellation. Hosted credentials were not used.
Compatibility/data Independent category defaults, duplicate behavior, settings serialization, standalone connection export/import, and profile credential-identity checks. Full legacy regression suite passed.
UI Desktop and mobile browser interactions plus light/dark screenshots. WebKit ran in the existing Playwright container with current browser binaries because host libraries are unavailable.

Local review

Initial CodeRabbit review completed with seven findings. Fixed failure-handling boundaries, the source-order regression assertion, normalized source reuse in import/export, and the connection-row type. Added a bounded DNS/cancellation race in the shared Decision transport; withLlmRequestTimeout was not used because it only scopes llmFetch options and cannot enforce a deadline on this safeFetch path. Retained the two short localized Test-result renderers instead of adding the suggested shared formatting abstraction. The follow-up server review completed with two minor findings. Fixed speaker attribution for single-speaker group replies and verified it through the real generation route. Retained the existing import-quarantine clearing boundary: saving the Connection editor already sends provider/base URL/model and clears the flag; a partial source/link API patch alone should not silently approve the rest of an imported connection.

Manual verification notes

  • Manually verify TypeSafe and OpenRouter with valid live credentials and account billing.
  • Manually verify a user-run Open-Jev endpoint with its actual model/tokenizer and hardware latency.
  • Manually verify custom-agent package export/import through the permission-review UI with activation settings.

These live-provider and hardware paths were not exercised by local mocks. The state budget uses estimates, and a server may still reject an input; rejection fails open.

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
  • Version/release files updated (only if this PR includes a version bump)

Updated docs/agents/custom-agents.md and CHANGELOG.md. Translation follow-up: #6532.

UI evidence (if applicable)

Before/after screenshots, including mobile and error states. Baseline is staging 0f8a90caf; all screenshots use fixture data.

Before After
Before image

Summary by CodeRabbit

  • New Features

    • Added optional activation questions for custom agents, with configurable probability thresholds and message-based bypass settings.
    • Added Decision connections supporting TypeSafe, OpenRouter, and custom System One endpoints.
    • Added connection testing, credential linking, state-token limits, import/export support, and relinking warnings.
    • Custom agents can now be conditionally activated before and after generation.
  • Documentation

    • Updated custom-agent documentation for activation keywords and questions.
  • Tests

    • Added end-to-end and regression coverage for activation behavior and Decision connections.

🔄 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/6531 **Author:** [@kolacheee](https://github.com/kolacheee) **Created:** 9/22/2026 **Status:** ✅ Merged **Merged:** 9/22/2026 **Merged by:** [@kolacheee](https://github.com/kolacheee) **Base:** `staging` ← **Head:** `codex/agent-activation-questions` --- ### 📝 Commits (6) - [`61067ce`](https://github.com/Pasta-Devs/Marinara-Engine/commit/61067ceae089000daeafa962ce5e3464fc61cd0d) feat(agents): define activation question settings - [`84285ff`](https://github.com/Pasta-Devs/Marinara-Engine/commit/84285ff2ba2d84dcf599959839f5671cff533df7) feat(agents): gate custom agents with System One decisions - [`92e8f80`](https://github.com/Pasta-Devs/Marinara-Engine/commit/92e8f806c4ad992133cda1f5b0c20f5fa9746146) fix(agents): retain decision context speaker identity - [`0b46f3d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/0b46f3dad024a0fa54e970d74ac087222ab9cefa) Merge remote-tracking branch 'origin/staging' into codex/agent-activation-questions - [`82cd9ea`](https://github.com/Pasta-Devs/Marinara-Engine/commit/82cd9ead314d0aeab5ae891c129790bda5d09b5b) fix(ui): group activation questions with keywords - [`c838386`](https://github.com/Pasta-Devs/Marinara-Engine/commit/c838386e10e9f6b1514664b24f5845db42a15b10) fix(ui): match question controls to keyword styling ### 📊 Changes **36 files changed** (+1945 additions, -53 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+2 -0) 📝 `docs/agents/custom-agents.md` (+31 -2) ➕ `e2e/agent-activation-questions.e2e.ts` (+369 -0) ➕ `packages/client/src/components/agents/ActivationQuestionFields.tsx` (+105 -0) 📝 `packages/client/src/components/agents/AgentEditor.tsx` (+59 -2) 📝 `packages/client/src/components/chat/StoryboardChatSettingsPanel.tsx` (+2 -1) 📝 `packages/client/src/components/chat/SummaryPopover.tsx` (+2 -1) 📝 `packages/client/src/components/connections/ConnectionEditor.tsx` (+190 -10) ➕ `packages/client/src/components/connections/DecisionDefaultControl.tsx` (+109 -0) 📝 `packages/client/src/components/modals/CreateConnectionModal.tsx` (+2 -2) 📝 `packages/client/src/components/panels/ConnectionsPanel.tsx` (+8 -2) 📝 `packages/client/src/components/panels/settings/TTSConfigCard.tsx` (+2 -1) 📝 `packages/client/src/hooks/use-connections.ts` (+21 -1) 📝 `packages/client/src/lib/connection-filters.ts` (+2 -1) 📝 `packages/client/src/lib/connection-transfer.ts` (+26 -0) 📝 `packages/client/src/localization/locales/en.json` (+54 -1) 📝 `packages/server/src/db/schema/connections.ts` (+4 -0) 📝 `packages/server/src/routes/backup.routes.ts` (+2 -0) 📝 `packages/server/src/routes/connections.routes.ts` (+33 -1) 📝 `packages/server/src/routes/conversation.routes.ts` (+1 -1) _...and 16 more files_ </details> ### 📄 Description ## Linked issue Closes #6530 ## Why this change Keyword-only activation misses paraphrases and scene changes. Custom agents can now ask a short yes/no question before running, such as “Did the location change?”, and run only when the returned probability meets their threshold. Existing keywords and cadence are checked first. Unavailable, late, or invalid decisions leave eligible agents enabled. ## What changed - Add a dedicated Decision connection for TypeSafe, OpenRouter, and custom System One endpoints, with an independent Decision model default and a fixed-sample Test action. - Resolve linked keys at request time, enforce provider and origin compatibility, preserve key rotation, warn before deleting a borrowed key, and require relinking after standalone imports. - Batch custom-agent questions by scan depth before generation and after the completed reply. Resolve agent macros, preserve recent messages within an estimated token budget, support a question-only maximum-skip override, and bound requests/cancellation including stalled DNS validation. - Add localized controls, setup/privacy guidance, and a mobile-accessible Save label in the agent editor. Question and its threshold/skip settings share the Activation Keywords card, using the same typography, colors, spacing, and input styling as Keywords and Scan Depth. This is the first System One implementation. Existing local chat-model decisions and managed Open-Jev installation remain separate phases. No storage-format or app-version change. The branch includes staging commit `89d2a9bb9` (memory correction/recovery fixes from #6527). ## 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` ### Recorded automated evidence - `pnpm check` passed on implementation head `0b46f3dad` after merging current staging, including localization, formatting, TypeScript, and production builds. One pre-existing GameNarration hook-dependency warning remains. - `pnpm regression:node`: **349/349 passed** again on implementation head `0b46f3dad`, including the newly merged memory regressions, stalled-DNS timeout and cancellation. `pnpm regression:prompt` and `pnpm check:e2e-types` passed on that head. - Focused `pnpm smoke:ui` across desktop Chromium, mobile Chromium, and mobile WebKit: **20 passed, 4 existing desktop-only cases skipped** on implementation head `0b46f3dad`. All nine new feature cases passed, together with the newly merged scene-recovery flow in all three browsers. Coverage includes saving/reloading questions, disabling/re-enabling defaults, 422 errors, OpenRouter key linking/deletion, and real generation routing against local mock providers. - The implementation at `84285ff2b` built as a Podman production image and its `/api/health` returned `status: ok`. The later speaker-metadata fix and staging merge are covered by the final local build and regression checks. - Latest UI validation at `c838386e1`: `pnpm check` and `pnpm check:e2e-types` passed; the existing Decision settings browser test passed on desktop Chromium, mobile Chromium, and mobile WebKit (**3/3**). Visually checked the shared card and matched Question/Keywords styles in desktop light/dark and mobile screenshots. Focused local CodeRabbit review completed with **zero findings**. ### Claim boundaries | Risk | Evidence | | --- | --- | | Agent routing | Real generation requests prove below-threshold skipping, above-threshold runs, fail-open on HTTP failure, completed-reply context, single-speaker group-chat attribution and macro expansion, no decision call for a keyword miss, and unchanged agents without questions. Saved successful runs are checked. | | Credentials/outbound requests | Regression covers rotating/deleted keys, wrong-origin links, quarantine, no copied linked key, redirect rejection, bounded responses, timeout, and cancellation. Hosted credentials were not used. | | Compatibility/data | Independent category defaults, duplicate behavior, settings serialization, standalone connection export/import, and profile credential-identity checks. Full legacy regression suite passed. | | UI | Desktop and mobile browser interactions plus light/dark screenshots. WebKit ran in the existing Playwright container with current browser binaries because host libraries are unavailable. | ### Local review Initial CodeRabbit review completed with seven findings. Fixed failure-handling boundaries, the source-order regression assertion, normalized source reuse in import/export, and the connection-row type. Added a bounded DNS/cancellation race in the shared Decision transport; `withLlmRequestTimeout` was not used because it only scopes `llmFetch` options and cannot enforce a deadline on this `safeFetch` path. Retained the two short localized Test-result renderers instead of adding the suggested shared formatting abstraction. The follow-up server review completed with two minor findings. Fixed speaker attribution for single-speaker group replies and verified it through the real generation route. Retained the existing import-quarantine clearing boundary: saving the Connection editor already sends provider/base URL/model and clears the flag; a partial source/link API patch alone should not silently approve the rest of an imported connection. ### Manual verification notes - [ ] Manually verify TypeSafe and OpenRouter with valid live credentials and account billing. - [ ] Manually verify a user-run Open-Jev endpoint with its actual model/tokenizer and hardware latency. - [ ] Manually verify custom-agent package export/import through the permission-review UI with activation settings. These live-provider and hardware paths were not exercised by local mocks. The state budget uses estimates, and a server may still reject an input; rejection fails open. ## 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 - [ ] Version/release files updated (only if this PR includes a version bump) Updated `docs/agents/custom-agents.md` and `CHANGELOG.md`. Translation follow-up: #6532. ## UI evidence (if applicable) [Before/after screenshots, including mobile and error states](https://gist.github.com/kolacheee/0427fc7f364e3f7ce7e4a12465555e7d). Baseline is staging `0f8a90caf`; all screenshots use fixture data. | Before | After | | --- | --- | | ![Before](https://gist.githubusercontent.com/kolacheee/0427fc7f364e3f7ce7e4a12465555e7d/raw/before-light.png) | <img width="1440" height="900" alt="image" src="https://github.com/user-attachments/assets/277c174e-6242-45e4-9ef5-c582bcb09b77" /> | <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Added optional activation questions for custom agents, with configurable probability thresholds and message-based bypass settings. - Added Decision connections supporting TypeSafe, OpenRouter, and custom System One endpoints. - Added connection testing, credential linking, state-token limits, import/export support, and relinking warnings. - Custom agents can now be conditionally activated before and after generation. - **Documentation** - Updated custom-agent documentation for activation keywords and questions. - **Tests** - Added end-to-end and regression coverage for activation behavior and Decision connections. <!-- 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:35 +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#7215
No description provided.