[PR #1043] [MERGED] Fix custom agent prompt section freshness #4894

Closed
opened 2026-10-22 04:11:30 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/1043
Author: @cha1latte
Created: 5/20/2026
Status: ✅ Merged
Merged: 5/20/2026
Merged by: @cha1latte

Base: staging ← Head: fix/issue-1034-agent-prompt-section


📝 Commits (2)

  • ee1bed4 Fix custom agent prompt section freshness
  • 811e579 Clarify active agent marker scope

📊 Changes

2 files changed (+65 additions, -17 deletions)

View changed files

📝 packages/server/src/routes/generate.routes.ts (+61 -14)
📝 packages/server/src/services/prompt/marker-expander.ts (+4 -3)

📄 Description

Linked issue

Closes #1034

Why this change

  • Custom pre-generation agent prompt sections could resolve from the last saved run before the current agent cadence run completed, leaving the prompt section one run behind and replaying stale output after agents were inactive.

What changed

  • Treat agent-data prompt sections as active-chat-only so inactive chats do not keep replaying the last saved custom agent run.
  • Include active custom pre-generation context_injection agents in the runtime placeholder path that is filled after the current agent run completes.
  • Reuse the preloaded agent config list for prompt-section eligibility and later agent resolution so the two paths stay aligned.

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

  • Codex scratch repro before the fix showed inactive and active-without-runtime custom agent prompt sections both contained PREVIOUS_OUTPUT, while the runtime replacement path contained CURRENT_OUTPUT.
  • Codex reran pnpm --filter @marinara-engine/server exec tsx ../../scratch/issue-1034-agent-section-repro.ts after the fix. It showed:
{
  "inactiveOutput": "",
  "activeWithoutRuntimeOutput": "<plot_consultant>\n    PREVIOUS_OUTPUT\n</plot_consultant>",
  "activeRouteOutput": "<plot_consultant>\n    CURRENT_OUTPUT\n</plot_consultant>",
  "inactiveCleared": true,
  "customAgentEligible": true,
  "routeRuntimePathWorks": true,
  "nonContextCustomEligible": false,
  "postProcessingCustomEligible": false,
  "edgeCasesPassed": true
}
  • Codex ran pnpm check; it passed.
  • Bunny review pass ran before opening this draft PR; no blocking findings.
  • No human-only verification blocker identified for the core prompt-assembly claim.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Version/release files updated (only if this PR includes a version bump)

UI evidence (if applicable)

N/A - backend prompt assembly behavior, verified with a focused scratch repro.

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced agent eligibility logic to properly evaluate both built-in and per-chat configured agents for prompt injection, ensuring accurate availability based on configuration.
    • Refined active agent filtering to ensure only explicitly enabled agents contribute their derived content when processing prompts.

Review Change Stack


🔄 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/1043 **Author:** [@cha1latte](https://github.com/cha1latte) **Created:** 5/20/2026 **Status:** ✅ Merged **Merged:** 5/20/2026 **Merged by:** [@cha1latte](https://github.com/cha1latte) **Base:** `staging` ← **Head:** `fix/issue-1034-agent-prompt-section` --- ### 📝 Commits (2) - [`ee1bed4`](https://github.com/Pasta-Devs/Marinara-Engine/commit/ee1bed4e5fd4203cfc30e1da5b739b1f65ba6843) Fix custom agent prompt section freshness - [`811e579`](https://github.com/Pasta-Devs/Marinara-Engine/commit/811e5795445063be90387d5c9d0fa1821bb26807) Clarify active agent marker scope ### 📊 Changes **2 files changed** (+65 additions, -17 deletions) <details> <summary>View changed files</summary> 📝 `packages/server/src/routes/generate.routes.ts` (+61 -14) 📝 `packages/server/src/services/prompt/marker-expander.ts` (+4 -3) </details> ### 📄 Description <!-- Target branch: `staging`. The default base in this UI is `main` (release branch). --> <!-- Change the base to `staging` before submitting unless this is a maintainer-approved mainline change. --> <!-- See CONTRIBUTING.md § Branches. --> ## Linked issue <!-- Every PR should reference a feature request or issue report. If there isn't one yet, open one first to gather opinions: --> <!-- https://github.com/Pasta-Devs/Marinara-Engine/issues/new/choose --> Closes #1034 ## Why this change <!-- What user problem, bug, or goal does this solve? --> - Custom pre-generation agent prompt sections could resolve from the last saved run before the current agent cadence run completed, leaving the prompt section one run behind and replaying stale output after agents were inactive. ## What changed <!-- List the key changes in this PR --> - Treat agent-data prompt sections as active-chat-only so inactive chats do not keep replaying the last saved custom agent run. - Include active custom pre-generation `context_injection` agents in the runtime placeholder path that is filled after the current agent run completes. - Reuse the preloaded agent config list for prompt-section eligibility and later agent resolution so the two paths stay aligned. ## Validation <!-- Required: include commands run and/or manual checks performed --> - [ ] `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 <!-- Describe exactly what you tested in a real browser/app, step by step. --> <!-- ⚠️ If an AI agent filled out or ticked these boxes for you, treat them --> <!-- as a TO-DO LIST, not as proof the work is done. Verify each item yourself --> <!-- before submitting. If you haven't verified it, untick the box. --> - Codex scratch repro before the fix showed inactive and active-without-runtime custom agent prompt sections both contained `PREVIOUS_OUTPUT`, while the runtime replacement path contained `CURRENT_OUTPUT`. - Codex reran `pnpm --filter @marinara-engine/server exec tsx ../../scratch/issue-1034-agent-section-repro.ts` after the fix. It showed: ```json { "inactiveOutput": "", "activeWithoutRuntimeOutput": "<plot_consultant>\n PREVIOUS_OUTPUT\n</plot_consultant>", "activeRouteOutput": "<plot_consultant>\n CURRENT_OUTPUT\n</plot_consultant>", "inactiveCleared": true, "customAgentEligible": true, "routeRuntimePathWorks": true, "nonContextCustomEligible": false, "postProcessingCustomEligible": false, "edgeCasesPassed": true } ``` - Codex ran `pnpm check`; it passed. - Bunny review pass ran before opening this draft PR; no blocking findings. - No human-only verification blocker identified for the core prompt-assembly claim. ## Docs and release impact - [x] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Version/release files updated (only if this PR includes a version bump) ## UI evidence (if applicable) N/A - backend prompt assembly behavior, verified with a focused scratch repro. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Enhanced agent eligibility logic to properly evaluate both built-in and per-chat configured agents for prompt injection, ensuring accurate availability based on configuration. * Refined active agent filtering to ensure only explicitly enabled agents contribute their derived content when processing prompts. <!-- review_stack_entry_start --> [![Review Change Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/Pasta-Devs/Marinara-Engine/pull/1043?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack) <!-- review_stack_entry_end --> <!-- 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-22 04:11:30 +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#4894
No description provided.