mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2994] [Issue]: Tool-using built-ins (lorebook-keeper, knowledge-retrieval, expression, combat) run with no tools in main generation but get them on retry #1568
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#1568
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 29, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2994
Originally assigned to: @SpicyMarinara on GitHub.
What's wrong
Built-in agents enabled purely via the chat agent picker (never opened/saved in the full Agent Editor) run WITHOUT their default tools during normal generation. Lorebook-keeper and knowledge-retrieval lose
search_lorebook, expression losesset_expression, combat losesroll_dice. The retry path re-injects the defaults, so the SAME agent behaves differently on retry vs normal generation — a visible capability loss and inconsistency (e.g. the lorebook-keeper can still write but can no longer look up existing entries before writing).How to reproduce (try it yourself)
You'll see: on retry the default tool is re-added, so the agent behaves differently than on normal generation.
Expected: the agent has its default tools on both paths, exactly as it does when configured through the editor.
Where it is
Root cause (fix site):
packages/server/src/services/generation/agent-resolution.ts:281-290(enabledConfigs branch) AND:400-409(builtInFallbacks branch) — both only inject DEFAULT_AGENT_TOOLS for spotify. Retry path that DOES re-inject for all built-ins:packages/server/src/routes/generate/retry-agents-route.ts:207-219(applyDefaultBuiltInAgentTools). Runtime gate that makes the omission observable:packages/server/src/services/generation/tool-resolution-runtime.ts:689(if (agentEnabledNames.length === 0) continue;). Contributing:packages/server/src/services/storage/agents.storage.ts:167(ensureBuiltinConfigseeds no enabledTools) vspackages/server/src/routes/agents.routes.ts:128-131(which adds them).What's happening
getDefaultBuiltInAgentSettings()intentionally omits enabledTools; only the route/editor path layers DEFAULT_AGENT_TOOLS on top. Both main-generation resolution branches only re-inject tools for spotify, so tool-using built-ins materialized or fallback-resolved without going through the editor run tool-less. The runtime gate then skips building any tool context when enabledTools is empty.Suggested fix
Fix the main-generation resolver so it matches the retry path for ALL built-ins, covering both the persisted (enabledConfigs) and first-generation (builtInFallbacks) paths, using
!Array.isArraysemantics so an explicit empty enabledTools (user removed all tools) is preserved, and excluding spotify (its provider-aware block is untouched).After the spotify block at line 290 (enabledConfigs loop):
After the spotify block at line 409 (builtInFallbacks loop):
(BUILT_IN_AGENTS and DEFAULT_AGENT_TOOLS are already imported in agent-resolution.ts.) This also re-injects defaults for already-persisted tool-less rows. Regression avoided: patching only
ensureBuiltinConfig(the suggested alt) is INSUFFICIENT — it does not fix the first-generation builtInFallbacks path (which runs before any DB row exists) nor existing tool-less rows. And the!Array.isArraycheck (not the spotify block'slength === 0predicate) is required so a user who deliberately removed all tools in the editor doesn't get them silently re-enabled. Optionally also seed enabledTools inensureBuiltinConfigfor consistency, but it is not sufficient alone.AI-investigated against v2.0.6; cited lines read and confirmed. Please verify before fixing.
@SpicyMarinara commented on GitHub (Jun 29, 2026):
Fixed in merged staging PR #3004.