mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2683] [Issue]: Agent connection resolution silently misroutes — deleted/empty-baseUrl falls back to main chat; empty model sends model="" #1331
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#1331
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 @kolacheee on GitHub (Jun 20, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2683
Originally assigned to: @SpicyMarinara on GitHub.
Summary
Agent connection resolution has two silent failure modes that misroute agent API calls: (1) a per-agent connection that was deleted, or has an empty/unresolvable base URL, silently falls back to the main chat connection/model with no warning; (2) a default-for-agents connection with an empty
modelis used anyway, sending agent requests withmodel="".Expected behavior
default_agent_connection_activewarning) — not silently run on the user's main (often paid) chat connection/model.model="".Actual behavior
(1)
resolveAgentConnectionProviderloads the agent's connection viaconnections.getWithKey(connectionId). Both a deleted connection (getWithKeyreturns null) and an empty resolved base URL fall through toreturn { provider: fallbackProvider, model: fallbackModel, ... }(the main chat provider/model) silently — the provider is only built inside anif (agentBaseUrl)guard, and thedefault_agent_connection_activewarning is only emitted when the effective connection is the default-for-agents one. A danglingconnectionIdis trivial to produce (agent.schema.tsconnectionIdisz.string().nullable()with no existence validation).(2)
getDefaultForAgentsreturns the first non-image connection flaggeddefaultForAgentsregardless of an emptymodelcolumn (schema default'');resolveAgentPipelineAgentscaches a provider withmodel: defaultAgentConn.model(no empty guard), and the executor passesmodel=''straight intoprovider.chatComplete.How it breaks the pipeline
Code trace (staging @
b826f8f4):packages/server/src/services/generation/agent-resolution.ts:130-155(resolveAgentConnectionProvider; fallback at:151-155; provider built only insideif (agentBaseUrl):132-133); warning gated at:260-262.connections.getWithKeynull atconnections.storage.ts:25-29. Empty baseUrl viaresolveBaseUrl(generate-route-utils.ts:769-778).connectionIdnullable atagent.schema.ts:49.connections.storage.ts:37-42(getDefaultForAgents, no model check);agent-resolution.ts:198-215(cachesmodel: defaultAgentConn.model,:211);agent-executor.ts:333-344/:696-707passmodelunvalidated. Empty model → provider 400; if batched,executeAgentBatchcatch marks all batch members failed.Steps to reproduce
Deleted connection: assign a custom agent to per-agent connection A (e.g. a local model), delete A while the agent still references its id, generate →
getWithKeyreturns null → the agent silently runs on the main chat provider/model.Empty model: mark a connection
default-for-agentsbut leave itsmodelblank, enable a built-in agent with no per-agent connection → the agent request goes out withmodel=''and the provider rejects it (and 400s the whole batch if batched).Suggested fix
Distinguish "no connection requested" from "connection found but unusable." When a non-null requested
connectionIdresolves to null (deleted), an empty base URL, or an empty/whitespace model: do not silently fall back to the main chat connection — skip the agent with anAgentConnectionWarning, or fall back to the default-for-agents connection and emitdefault_agent_connection_active. At minimumlogger.warnthe dangling/unusable connection id and skip dispatchingmodel=''.Environment
b826f8f4)Additional context
Found via a systematic multi-agent audit of the agent subsystem. Distinct from the blank-key bug (#2656): here the key is fine, but the connection identity/model is wrong. Part of a set of agent-pipeline issues filed together.
Template check
Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:
@SpicyMarinara commented on GitHub (Jun 21, 2026):
Addressed on the issue-sweep branch. Main generation and manual agent retry now distinguish no agent connection requested from a requested/default agent connection that is deleted, has no resolvable Base URL, or has no selected model. Unusable requested/default agent connections skip the affected agents with an SSE warning instead of silently falling back to the chat model or dispatching model=""; valid default-for-agents usage still emits the existing default-agent warning. Final repo checks will run after the sweep.