mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #7107] [Bug]: Re-importing an updated .agent.zip creates a duplicate agent instead of updating it #3971
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#3971
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Chronophylos on GitHub (Oct 5, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/7107
Problem
Re-importing an updated
.agent.zipdoes not update the agent you already have — it creates a second agent with the same name. There is no update path anywhere in the import flow, so every version a user imports accumulates as another row.Why
POST /api/agents/importcallsstorage.create()unconditionally and never looks for a pre-existing agent to update:packages/server/src/routes/agents.routes.ts:250—return storage.create(buildImportedAgentInput(input));packages/server/src/services/storage/agents.storage.ts:247-277—create()only updates in place for built-in types (isBuiltInAgentType). Custom types always getnewId()and a fresh row.The archive carries no stable identity to match on:
createAgentConfigSchema(packages/shared/src/schemas/agent.schema.ts:71-83) has noid/externalId/sourceId, and zod strips unknown keys, so a manifest id would be discarded anyway. Export (packages/client/src/lib/agent-transfer.ts:161-204) drops the row id when writing the manifest.The panel then compounds it: the type is re-randomized twice per import, once on the client and again on the server.
packages/client/src/lib/agent-transfer.ts:115—createImportedAgentType(sourceType)packages/server/src/routes/agents.routes.ts:169—type: createImportedAgentType(input.agent.type)createImportedAgentType(packages/shared/src/types/agent.ts:682-693) appends a freshcrypto.randomUUID()each call, so a re-import yields:Two re-imports produce two unrelated types.
keepLatestConfigPerType(agents.storage.ts:38-47), which is what hides duplicate rows from the list, dedupes by type — so it keeps both. Two "Body State" agents appear side by side.Impact
Beyond the duplicate row:
agentOverrideskeyed by<type>(packages/shared/src/types/chat.ts:338,chat-presets.storage.ts:70). A new type means the new agent starts with no enable/disable state in every chat, and the old agent's state is stranded under a type that no longer resolves.Reproduction
Body-State.agent.zipvia Agents → Import. Note the resulting agent.Suggested direction
Give the archive a stable identity that survives export/import, then have the import handler upsert on it:
config.externalId) and tocreateAgentConfigSchema, and write it on export.buildImportedAgentInput, look up an existing agent byexternalIdbeforestorage.create(). If found,storage.update(existing.id, …)and keep the existingtype— that also preserves the chat'sagentOverrideskeys and the run history.custom-import-…type when noexternalIdis present (hand-written agents, older archives).Also worth fixing on its own: the type is randomized twice per import. The server-side re-randomization compounds the slug into
custom-import-custom-import-…, which is user-visible and makes types unreadable in logs.Note
Reported from a Body State agent + panel integration. The panel works around this by resolving the agent by name (
resolveAgentType), which happens to find the newest row, but that is a workaround for the missing identity — it cannot disambiguate two same-named agents and will silently bind to whichever rowlistLatest()returns first.