[PR #803] [MERGED] Fix custom agent prompt section names #4775

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

📋 Pull Request Information

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

Base: main ← Head: fix/issue-789-agent-prompt-tag


📝 Commits (1)

  • 04f6f15 Fix custom agent prompt section names

📊 Changes

10 files changed (+88 additions, -34 deletions)

View changed files

➕ docs/pr-evidence/issue-789/repro-output.json (+25 -0)
📝 packages/client/src/components/agents/ContextInjectionPanel.tsx (+19 -13)
📝 packages/client/src/components/chat/ChatArea.tsx (+1 -0)
📝 packages/client/src/hooks/use-generate.ts (+1 -1)
📝 packages/server/src/routes/generate.routes.ts (+27 -15)
📝 packages/server/src/routes/generate/agent-normalizers.ts (+8 -2)
📝 packages/server/src/routes/generate/retry-agents-route.ts (+2 -1)
📝 packages/server/src/services/agents/agent-pipeline.ts (+3 -1)
📝 packages/shared/src/schemas/chat.schema.ts (+1 -0)
📝 packages/shared/src/types/chat.ts (+1 -1)

📄 Description

Linked issue

Closes #789

Why this change

  • Pre-generation custom agent prompt sections were wrapped with tags derived from the agent's stable type, which is generated from the original name. After renaming a custom agent, the main prompt could still show the stale original name in the wrapper.
  • The stale wrapper text is visible to the main model, so names like test-agent can influence how seriously the model treats the injected section.

What changed

  • Preserve the current agent display name on pre-generation context injections while keeping agentType as the stable matching key.
  • Format XML/Markdown prompt-section wrappers from the current display name, with legacy fallback to agentType for older cached injections.
  • Carry agentName through cached injection normalization, retry-agent cache refresh, injection review overrides, and the cached injections panel label.
  • Added committed command-output proof at docs/pr-evidence/issue-789/repro-output.json.

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

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)

No user-facing docs or release metadata changes are needed. The committed file under docs/pr-evidence/ is PR proof only.

UI evidence (if applicable)

N/A. This is prompt assembly / cached injection metadata behavior, not a visible UI rendering bug. Command-output proof is linked above.


🔄 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/803 **Author:** [@cha1latte](https://github.com/cha1latte) **Created:** 5/13/2026 **Status:** ✅ Merged **Merged:** 5/13/2026 **Merged by:** [@cha1latte](https://github.com/cha1latte) **Base:** `main` ← **Head:** `fix/issue-789-agent-prompt-tag` --- ### 📝 Commits (1) - [`04f6f15`](https://github.com/Pasta-Devs/Marinara-Engine/commit/04f6f1567996373315ac3faa4144363eaf5808b2) Fix custom agent prompt section names ### 📊 Changes **10 files changed** (+88 additions, -34 deletions) <details> <summary>View changed files</summary> ➕ `docs/pr-evidence/issue-789/repro-output.json` (+25 -0) 📝 `packages/client/src/components/agents/ContextInjectionPanel.tsx` (+19 -13) 📝 `packages/client/src/components/chat/ChatArea.tsx` (+1 -0) 📝 `packages/client/src/hooks/use-generate.ts` (+1 -1) 📝 `packages/server/src/routes/generate.routes.ts` (+27 -15) 📝 `packages/server/src/routes/generate/agent-normalizers.ts` (+8 -2) 📝 `packages/server/src/routes/generate/retry-agents-route.ts` (+2 -1) 📝 `packages/server/src/services/agents/agent-pipeline.ts` (+3 -1) 📝 `packages/shared/src/schemas/chat.schema.ts` (+1 -0) 📝 `packages/shared/src/types/chat.ts` (+1 -1) </details> ### 📄 Description ## 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 #789 ## Why this change <!-- What user problem, bug, or goal does this solve? --> - Pre-generation custom agent prompt sections were wrapped with tags derived from the agent's stable type, which is generated from the original name. After renaming a custom agent, the main prompt could still show the stale original name in the wrapper. - The stale wrapper text is visible to the main model, so names like `test-agent` can influence how seriously the model treats the injected section. ## What changed <!-- List the key changes in this PR --> - Preserve the current agent display name on pre-generation context injections while keeping `agentType` as the stable matching key. - Format XML/Markdown prompt-section wrappers from the current display name, with legacy fallback to `agentType` for older cached injections. - Carry `agentName` through cached injection normalization, retry-agent cache refresh, injection review overrides, and the cached injections panel label. - Added committed command-output proof at `docs/pr-evidence/issue-789/repro-output.json`. ## 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 reproduced the bug before the fix with `pnpm --filter @marinara-engine/server exec tsx ../../scratch/issue-789-repro.ts`; the prompt wrapper used `<custom-test-agent-a9e721ff-9ea8-4c8a-ba9d-5f3885fb30ba>`. - Codex reran the same repro after the fix and verified the wrapper now uses `<probability_engine>` for the renamed custom agent. - Codex also verified Markdown wrappers, multiple injected agents, and legacy cached injections that only have `{ agentType, text }`. - Codex ran `pnpm check` successfully after rebasing onto current `upstream/main`. - Proof artifact: https://raw.githubusercontent.com/cha1latte/Marinara-Engine/04f6f1567996373315ac3faa4144363eaf5808b2/docs/pr-evidence/issue-789/repro-output.json ## 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) No user-facing docs or release metadata changes are needed. The committed file under `docs/pr-evidence/` is PR proof only. ## UI evidence (if applicable) N/A. This is prompt assembly / cached injection metadata behavior, not a visible UI rendering bug. Command-output proof is linked above. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:10:32 +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#4775
No description provided.