[GH-ISSUE #3832] [Issue]: Package uninstall leaves secondary agent state for multi-agent packages #2068

Closed
opened 2026-10-21 05:45:04 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @Xelvanis on GitHub (Jul 19, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/3832

Originally assigned to: @SpicyMarinara on GitHub.

Summary

Package uninstall cleanup removes chat selections and stored agent configuration using only the package ID. The documented capability contract allows one package to contribute multiple agent definitions, so any secondary agent IDs remain as stale chat references and orphaned configuration after uninstall.

No current official package is known to trigger this: all 29 packages in the current Marinara-Agents catalog contain one same-named agent. This is a latent contract bug rather than an active production regression.

Expected behavior

Uninstalling a package should remove every agent definition supplied by that package from active chat selections and delete each corresponding agent configuration/runtime record, while preserving historical chat content as documented.

Actual behavior

  1. A package may contain an array of agent definitions, and the runtime registry registers every definition.id.
  2. Chats store those definition IDs in metadata.activeAgentIds; configurations are stored by definition type.
  3. The uninstall route calls capabilityPackageManager.uninstall(id), which removes the package registry entry and deletes its version directory.
  4. Cleanup then filters activeAgentIds and deletes a configuration using only the package ID.
  5. Secondary definition IDs therefore remain in chat metadata, and their configurations/memory remain stored even though their runtime definitions are gone.

Relevant source at the audited staging revision:

Steps to reproduce

  1. Create a valid catalog fixture whose package ID is agent-suite and whose agents.json defines both agent-suite and suite-helper.
  2. Install the package, create/configure both agents, and add both definition IDs to a chat's activeAgentIds.
  3. Uninstall agent-suite through /api/capability-packages/agent-suite.
  4. Inspect the chat metadata and agent configuration storage.
  5. Observe that agent-suite is removed, while suite-helper remains referenced/configured without a live package definition.

Environment

  • Marinara Engine version: 2.3.3 (staging revision e2aaec9bf327a686f4471deac96c1076632994d2)
  • Install type: source audit
  • OS + version: Not platform-specific; this is a package-lifecycle contract issue
  • Browser or app shell: Not applicable

Logs, screenshots, or video

A direct schema/filter check produced:

{"packageId":"agent-suite","definitionIds":["agent-suite","suite-helper"],"remainingAfterCurrentFilter":["suite-helper"]}

A complete database-backed uninstall was not executed during the audit; the storage and route sequence was verified statically.

Additional context

At Marinara-Agents commit 51eed186, all 29 official agents.json files contain exactly one agent whose ID matches its package ID. The catalog validator requires a matching primary ID but permits additional definitions, so a future supported multi-agent package would expose this path.

The smallest fix is to resolve and retain all package-owned definition IDs before deleting the package version directory, then clean chat selections and configurations for that full set. Uninstall should still succeed with a safe package-ID fallback if the definition file is missing or corrupt.

Adjacent agent-keyed metadata such as prompt-template selections and overrides should be considered when defining the cleanup set, without deleting historical chat messages or completed feature data.

Template check

Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @Xelvanis on GitHub (Jul 19, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/3832 Originally assigned to: @SpicyMarinara on GitHub. ## Summary Package uninstall cleanup removes chat selections and stored agent configuration using only the package ID. The documented capability contract allows one package to contribute multiple agent definitions, so any secondary agent IDs remain as stale chat references and orphaned configuration after uninstall. No current official package is known to trigger this: all 29 packages in the current Marinara-Agents catalog contain one same-named agent. This is a latent contract bug rather than an active production regression. ## Expected behavior Uninstalling a package should remove every agent definition supplied by that package from active chat selections and delete each corresponding agent configuration/runtime record, while preserving historical chat content as documented. ## Actual behavior 1. A package may contain an array of agent definitions, and the runtime registry registers every `definition.id`. 2. Chats store those definition IDs in `metadata.activeAgentIds`; configurations are stored by definition type. 3. The uninstall route calls `capabilityPackageManager.uninstall(id)`, which removes the package registry entry and deletes its version directory. 4. Cleanup then filters `activeAgentIds` and deletes a configuration using only the package ID. 5. Secondary definition IDs therefore remain in chat metadata, and their configurations/memory remain stored even though their runtime definitions are gone. Relevant source at the audited `staging` revision: - [The package architecture permits one or more declarative agents](https://github.com/Pasta-Devs/Marinara-Engine/blob/e2aaec9bf327a686f4471deac96c1076632994d2/docs/development/optional-agent-packages.md#L9-L18) - [The shared schema accepts an array of agent definitions](https://github.com/Pasta-Devs/Marinara-Engine/blob/e2aaec9bf327a686f4471deac96c1076632994d2/packages/shared/src/schemas/capability-package.schema.ts#L143-L164) - [Runtime registration uses every definition ID](https://github.com/Pasta-Devs/Marinara-Engine/blob/e2aaec9bf327a686f4471deac96c1076632994d2/packages/server/src/services/capability-packages/package-manager.service.ts#L362-L378) - [Uninstall deletes package files before route-level cleanup](https://github.com/Pasta-Devs/Marinara-Engine/blob/e2aaec9bf327a686f4471deac96c1076632994d2/packages/server/src/services/capability-packages/package-manager.service.ts#L529-L538) - [Route cleanup uses only the package ID](https://github.com/Pasta-Devs/Marinara-Engine/blob/e2aaec9bf327a686f4471deac96c1076632994d2/packages/server/src/routes/capability-packages.routes.ts#L39-L65) ## Steps to reproduce 1. Create a valid catalog fixture whose package ID is `agent-suite` and whose `agents.json` defines both `agent-suite` and `suite-helper`. 2. Install the package, create/configure both agents, and add both definition IDs to a chat's `activeAgentIds`. 3. Uninstall `agent-suite` through `/api/capability-packages/agent-suite`. 4. Inspect the chat metadata and agent configuration storage. 5. Observe that `agent-suite` is removed, while `suite-helper` remains referenced/configured without a live package definition. ## Environment - Marinara Engine version: 2.3.3 (`staging` revision `e2aaec9bf327a686f4471deac96c1076632994d2`) - Install type: source audit - OS + version: Not platform-specific; this is a package-lifecycle contract issue - Browser or app shell: Not applicable ## Logs, screenshots, or video A direct schema/filter check produced: ```json {"packageId":"agent-suite","definitionIds":["agent-suite","suite-helper"],"remainingAfterCurrentFilter":["suite-helper"]} ``` A complete database-backed uninstall was not executed during the audit; the storage and route sequence was verified statically. ## Additional context At [Marinara-Agents commit `51eed186`](https://github.com/Pasta-Devs/Marinara-Agents/commit/51eed1860dd549f515e30857fb75434782a34a53), all 29 official `agents.json` files contain exactly one agent whose ID matches its package ID. The catalog validator requires a matching primary ID but permits additional definitions, so a future supported multi-agent package would expose this path. The smallest fix is to resolve and retain all package-owned definition IDs before deleting the package version directory, then clean chat selections and configurations for that full set. Uninstall should still succeed with a safe package-ID fallback if the definition file is missing or corrupt. Adjacent agent-keyed metadata such as prompt-template selections and overrides should be considered when defining the cleanup set, without deleting historical chat messages or completed feature data. ## Template check Please **uncheck (untick)** the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:45:04 +07:00
  • closed this issue
  • added the
    in-pr
    label
Author
Owner

@SpicyMarinara commented on GitHub (Jul 19, 2026):

Claimed by @SpicyMarinara in draft PR #3835 for this assigned issue sweep.

<!-- gh-comment-id:5016973225 --> @SpicyMarinara commented on GitHub (Jul 19, 2026): Claimed by @SpicyMarinara in draft PR #3835 for this assigned issue sweep.
Author
Owner

@SpicyMarinara commented on GitHub (Jul 19, 2026):

Addressed in #3835: uninstall resolves every package-owned agent definition before deleting files, then cleans their chat metadata, configurations, runs, and memory with a safe package-ID fallback.

<!-- gh-comment-id:5017046673 --> @SpicyMarinara commented on GitHub (Jul 19, 2026): Addressed in #3835: uninstall resolves every package-owned agent definition before deleting files, then cleans their chat metadata, configurations, runs, and memory with a safe package-ID fallback.
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#2068
No description provided.