[PR #5526] [MERGED] Fix capability agent result finalization order #6796

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/5526
Author: @SpicyMarinara
Created: 8/25/2026
Status: ✅ Merged
Merged: 8/25/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/5525-capability-agent-finalization


📝 Commits (3)

  • b3d296f fix(agents): publish capability results after validation
  • eeaa08c fix(agents): honor package context selectors
  • 2ef6a27 fix(agents): guard alternate result paths

📊 Changes

6 files changed (+59 additions, -3 deletions)

View changed files

📝 CHANGELOG.md (+4 -0)
📝 packages/server/src/routes/generate.routes.ts (+11 -2)
📝 packages/server/src/services/agents/agent-executor.ts (+3 -1)
📝 packages/server/src/services/capability-packages/capability-agent-runtime.service.ts (+4 -0)
📝 scripts/regressions/capability-agent-runtime.regression.ts (+4 -0)
📝 scripts/regressions/prompt.regression.ts (+33 -0)

📄 Description

Why

Capability-package post-processing output was reaching the browser before the package runtime could validate or normalize it. Memory Nag therefore exposed a model-selected character ID even though its finalizer would reject that value as a nonexistent memory. Package-defined built-ins also had no way to narrow the host lore sources supplied to their calls.

Closes #5525

Companion package: Pasta-Devs/Marinara-Agents#599

What changed

  • defer browser events for agents with a registered runtime finalizer
  • publish the result once, after package finalization
  • honor explicit contextSources on package-defined built-in Agents while preserving the full-context default for existing built-ins
  • cover runtime event deferral and built-in context selection in focused regressions

Validation

  • pnpm check
  • pnpm exec tsx scripts/regressions/capability-agent-runtime.regression.ts
  • pnpm regression:prompt
  • Manually update Memory Nag 1.0.16 and verify a turn publishes only its validated recall result

Local focused results: capability runtime and complete prompt regressions passed; Prettier and git diff --check passed. Full workspace validation is delegated to the hosted PR lane.

Summary by CodeRabbit

  • Bug Fixes

    • Improved capability-agent result processing so deferred and retry results are published only after finalization.
    • Applied configured context sources consistently to built-in agents.
    • Ensured built-in agents can use chat-history-only context without unrelated context being included.
    • Added validation before publishing post-processing results.
  • Tests

    • Added regression coverage for deferred capability results and built-in agent context selection.

🔄 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/5526 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 8/25/2026 **Status:** ✅ Merged **Merged:** 8/25/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/5525-capability-agent-finalization` --- ### 📝 Commits (3) - [`b3d296f`](https://github.com/Pasta-Devs/Marinara-Engine/commit/b3d296f30a42e9361e577956ee5048c980b8a66a) fix(agents): publish capability results after validation - [`eeaa08c`](https://github.com/Pasta-Devs/Marinara-Engine/commit/eeaa08ca35ab8fe92a71d92da3b6b507e5ef0604) fix(agents): honor package context selectors - [`2ef6a27`](https://github.com/Pasta-Devs/Marinara-Engine/commit/2ef6a270b7ed6f1e1e6f8b81f105c0237d5b9fdd) fix(agents): guard alternate result paths ### 📊 Changes **6 files changed** (+59 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+4 -0) 📝 `packages/server/src/routes/generate.routes.ts` (+11 -2) 📝 `packages/server/src/services/agents/agent-executor.ts` (+3 -1) 📝 `packages/server/src/services/capability-packages/capability-agent-runtime.service.ts` (+4 -0) 📝 `scripts/regressions/capability-agent-runtime.regression.ts` (+4 -0) 📝 `scripts/regressions/prompt.regression.ts` (+33 -0) </details> ### 📄 Description ## Why Capability-package post-processing output was reaching the browser before the package runtime could validate or normalize it. Memory Nag therefore exposed a model-selected character ID even though its finalizer would reject that value as a nonexistent memory. Package-defined built-ins also had no way to narrow the host lore sources supplied to their calls. Closes #5525 Companion package: Pasta-Devs/Marinara-Agents#599 ## What changed - defer browser events for agents with a registered runtime finalizer - publish the result once, after package finalization - honor explicit `contextSources` on package-defined built-in Agents while preserving the full-context default for existing built-ins - cover runtime event deferral and built-in context selection in focused regressions ## Validation - [ ] `pnpm check` - [ ] `pnpm exec tsx scripts/regressions/capability-agent-runtime.regression.ts` - [ ] `pnpm regression:prompt` - [ ] Manually update Memory Nag 1.0.16 and verify a turn publishes only its validated recall result Local focused results: capability runtime and complete prompt regressions passed; Prettier and `git diff --check` passed. Full workspace validation is delegated to the hosted PR lane. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Bug Fixes** - Improved capability-agent result processing so deferred and retry results are published only after finalization. - Applied configured context sources consistently to built-in agents. - Ensured built-in agents can use chat-history-only context without unrelated context being included. - Added validation before publishing post-processing results. - **Tests** - Added regression coverage for deferred capability results and built-in agent context selection. <!-- 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:13:49 +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#6796
No description provided.