[GH-ISSUE #2996] [Issue]: Retry-agents resolution does not filter runtime-disabled/retired built-ins, unlike the main generation path #1569

Closed
opened 2026-10-21 05:39:24 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @kolacheee on GitHub (Jun 29, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2996

Originally assigned to: @SpicyMarinara on GitHub.

What's wrong
The main generation path excludes runtime-disabled and retired built-in agents from resolution. The retry path's resolver does not — it only filters deleted configs and builds its built-in fallback list straight from BUILT_IN_AGENTS without the runtime-disabled/retired guards. So a direct retry request for a runtime-disabled built-in (currently the html agent) in roleplay mode resolves an agent the main pipeline would never run, issuing a real LLM call whose result type is unhandled — a wasted model call and tokens.

How to reproduce (try it yourself)

  1. Have (or create) a stored html agent config (legacy).
  2. POST /generate/retry-agents with { chatId, agentTypes: ["html"] } for a roleplay-mode chat.

You'll see: html is included in resolvedAgents and an agent LLM call is issued, even though it is runtime-disabled and the main /generate path skips it.
Expected: runtime-disabled built-ins are skipped on retry as they are during generation. (Note: the bundled client has no retry trigger for html, so this is reachable via a direct API call.)

Where it is
packages/server/src/routes/generate/retry-agents-route.ts:947-953 (resolveRetryAgents — enabledConfigs filter and builtInFallbackConfigs build). Main-path comparison: packages/server/src/services/generation/agent-resolution.ts:226-231 and :366.

What's happening
The retry resolver duplicates the main resolver's enabled/fallback logic but omits the isBuiltInAgentRuntimeDisabled and isRetiredBuiltInAgentId guards, so the two paths disagree on which built-ins may run.

Suggested fix
Mirror the main path AND add the missing imports (neither symbol is currently imported in retry-agents-route.ts, so the bare suggested fix would fail pnpm check with TS2304).

  1. Add to the @marinara-engine/shared import block: isBuiltInAgentRuntimeDisabled, and isRetiredBuiltInAgentId,.
  2. Update enabledConfigs (947-949):
  const enabledConfigs = configs.filter(
    (config: any) =>
      !isAgentConfigDeleted(config.settings) &&
      !isBuiltInAgentRuntimeDisabled(config.type) &&
      !isRetiredBuiltInAgentId(config.type) &&
      agentTypeSet.has(config.type),
  );
  1. Update builtInFallbackConfigs (951-953):
  const builtInFallbackConfigs = BUILT_IN_AGENTS.filter(
    (agent) =>
      agentTypeSet.has(agent.id) &&
      !resolvedTypeSet.has(agent.id) &&
      !isBuiltInAgentRuntimeDisabled(agent.id),
  );

(Retired ids are already absent from BUILT_IN_AGENTS, so no retired check is needed in step 3, matching agent-resolution.ts:361-369.) Both guards are no-ops for custom DB agents and for active built-ins, so no legitimate retry target is newly blocked.


AI-investigated against v2.0.6; cited lines read and confirmed. Please verify before fixing.

Originally created by @kolacheee on GitHub (Jun 29, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2996 Originally assigned to: @SpicyMarinara on GitHub. **What's wrong** The main generation path excludes runtime-disabled and retired built-in agents from resolution. The retry path's resolver does not — it only filters deleted configs and builds its built-in fallback list straight from BUILT_IN_AGENTS without the runtime-disabled/retired guards. So a direct retry request for a runtime-disabled built-in (currently the `html` agent) in roleplay mode resolves an agent the main pipeline would never run, issuing a real LLM call whose result type is unhandled — a wasted model call and tokens. **How to reproduce (try it yourself)** 1. Have (or create) a stored `html` agent config (legacy). 2. POST /generate/retry-agents with `{ chatId, agentTypes: ["html"] }` for a roleplay-mode chat. You'll see: `html` is included in resolvedAgents and an agent LLM call is issued, even though it is runtime-disabled and the main /generate path skips it. Expected: runtime-disabled built-ins are skipped on retry as they are during generation. (Note: the bundled client has no retry trigger for html, so this is reachable via a direct API call.) **Where it is** `packages/server/src/routes/generate/retry-agents-route.ts:947-953` (`resolveRetryAgents` — enabledConfigs filter and builtInFallbackConfigs build). Main-path comparison: `packages/server/src/services/generation/agent-resolution.ts:226-231` and `:366`. **What's happening** The retry resolver duplicates the main resolver's enabled/fallback logic but omits the `isBuiltInAgentRuntimeDisabled` and `isRetiredBuiltInAgentId` guards, so the two paths disagree on which built-ins may run. **Suggested fix** Mirror the main path AND add the missing imports (neither symbol is currently imported in retry-agents-route.ts, so the bare suggested fix would fail `pnpm check` with TS2304). 1. Add to the `@marinara-engine/shared` import block: `isBuiltInAgentRuntimeDisabled,` and `isRetiredBuiltInAgentId,`. 2. Update enabledConfigs (947-949): ```ts const enabledConfigs = configs.filter( (config: any) => !isAgentConfigDeleted(config.settings) && !isBuiltInAgentRuntimeDisabled(config.type) && !isRetiredBuiltInAgentId(config.type) && agentTypeSet.has(config.type), ); ``` 3. Update builtInFallbackConfigs (951-953): ```ts const builtInFallbackConfigs = BUILT_IN_AGENTS.filter( (agent) => agentTypeSet.has(agent.id) && !resolvedTypeSet.has(agent.id) && !isBuiltInAgentRuntimeDisabled(agent.id), ); ``` (Retired ids are already absent from BUILT_IN_AGENTS, so no retired check is needed in step 3, matching agent-resolution.ts:361-369.) Both guards are no-ops for custom DB agents and for active built-ins, so no legitimate retry target is newly blocked. --- *AI-investigated against v2.0.6; cited lines read and confirmed. Please verify before fixing.*
Author
Owner

@SpicyMarinara commented on GitHub (Jun 29, 2026):

Fixed in merged staging PR #3004.

<!-- gh-comment-id:4832282276 --> @SpicyMarinara commented on GitHub (Jun 29, 2026): Fixed in merged staging PR #3004.
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#1569
No description provided.