mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #5957] Let a Game chat run tool calls on a different connection than its narration #3299
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#3299
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 (Sep 8, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5957
Originally assigned to: @SpicyMarinara on GitHub.
Ask: let a Game chat run its tool calls on a different connection than its narration — e.g. narrate on a Claude subscription connection while
roll_diceand friends execute against a Gemini API connection.First, a correction to the premise this started from: Professor Mari does not have this. Verified across both trees with explicit negative searches —
mariModel,toolsConnection,utilityConnection,auxConnection,secondaryConnection,connectionIdOverrideall return zero matches. Mari holds exactly one connection id (marinara:home-professor-mari-connection-id,HomeProfessorMariChat.tsx:134), her follow-up generation pass loops back into the samewhilewith the same resolved provider (generate.routes.ts:10736-10791, which never touchesconn), and her workspace agent builds one provider for an entire multi-round tool run (workspace-agent.service.ts:2631, the onlycreateProviderForConnectioncall in the file). Her bracket commands aren't LLM calls at all — they're local database work.But the shape absolutely does ship, twice, which is probably the real memory:
CustomEmojiSelectionPrefs.toolConnectionId, documented as "Connection used for the tool-call selection mode" (shared/src/schemas/custom-emoji.schema.ts:36-43), consumed atroutes/generate/conversation-custom-assets.ts:290-301. "Chat on one connection, tool call on another" is a shipped behavior — just for emoji, not Mari and not the GM.gameVideoConnectionId(shared/src/types/chat.ts:593), resolved by exactly the layered pattern this feature would want (game.routes.ts:1696-1709): per-chat metadata → setup-wizard default → purpose-scoped global default. Andconnections.storage.tsalready defines default/fallback pairs for four purposes (agents, image, video, audio). AgameGmToolConnectionIdplusgetDefaultForGmTools/getFallbackForGmToolswould drop straight into that family.So the settings plumbing is a known pattern. The hard part is the tool loop. Today the connection, provider, model and every generation parameter are resolved once, before any round runs (
generate.routes.ts:3290viaresolveGenerationProviderRuntime), and every round — including the final follow-up — closes over that sameproviderandconn. Three provider-locked side channels break if a different provider handles a round mid-turn:providerMetadata.geminiParts(google.provider.ts:793-816, consumed at:480-483). No other provider's formatter reads it, so a round handled elsewhere drops the signature, and handing back to Gemini can't manufacture one — with the in-code warning that Gemini 3 rejects a replayed call whose signature moved (google.provider.ts:703-704).generate.routes.ts:1223, written back at:6515-6520), and only the Responses-API path reads them. Switching away silently drops reasoning continuity.enableCaching/cachingAtDepthare read off the single connection on every call; cache economics depend on the array's shape staying stable, and there's no per-round hook to re-resolve any of it for a second connection.So this is a structural change to the loop, not a config flag — if it's done as a mid-turn provider switch.
Two designs, and the cheaper one is already precedented:
tool_usechain. This is exactly how emoji tool-call selection works, how the smart-group-responder selector works (generate.routes.ts:5860-5915, which builds a whole separate provider mid-request), and howknowledge-routerworks. None of the three side channels above are touched, because nothing crosses providers. The cost: the narrating model no longer decides in-band to call the tool — something else has to decide, or the GM has to signal its intent in text.Worth deciding which problem we're solving, because there may be a third answer. If the motivation is "subscription users can't use GM tools at all", the Engine already has a provider-agnostic channel that needs no tools API: the GM verb bracket tags (#5798) and server-rolled skill checks (#5923) are parsed out of narration text, which is why they already work on subscription connections. Extending that channel may serve those users better than routing tools to a second connection. If the motivation is instead "let power users put tool work on a cheaper or faster model", then the connection override is the right feature and the side-call shape is the way in.
Related: #5955 (GM lorebook search) would inherit whichever answer lands here.
@kolacheee commented on GitHub (Sep 8, 2026):
Correction to this issue's motivation, after verification — the subscription-user rationale doesn't hold, and should be struck.
This was filed partly so users on Claude/Grok subscription connections could get tool-driven behavior (real dice) by routing tool calls to a second connection. Checked against the code: that cannot work under any design, because there is never a tool call to route. Both subscription providers inherit
chatCompletefromBaseLLMProvider, which returns a hardcodedtoolCalls: [](base-provider.ts:783/:805) and never readsoptions.tools. The tool loop enters (the method exists), then breaks unconditionally on round 0. Any router keyed onresult.toolCallsfires zero times. The narrating model on those connections cannot emit a call, so there is nothing for a second connection to execute.The three candidate shapes, tested:
selectCustomAssetNamesByToolCallreadsresult.content, inspects the user's message, and runs as a pre-pass that edits the system prompt before the narrating model runs. It can't produce in-turn reaction, because the narration is already streamed before any post-pass could run — getting the GM to react would mean re-invoking the expensive narrating provider, which erases the saving. And for dice specifically, a narration that already invented "you rolled a 14" gives the judge nothing honest to work from.connection-fallback-provider.ts:331actively refuses to fall back when a subscription turn produced usable content, and it would replace the voice the user is paying for on exactly the turns that matter most.So the honest scope for this issue is cost control on a working tool loop — let users put tool work on a cheaper or faster model where the tool loop already runs. That's a real want and worth building. It just helps API/tool-capable users, and does nothing for subscription users; their path is the text-tag channel.
Two things follow for whoever picks this up:
@SpicyMarinara commented on GitHub (Sep 9, 2026):
@SpicyMarinara owns this sweep implementation in draft #5982. The separate connection will run an isolated tool-planning pass before narration, returning actual tool results as text so provider-specific reasoning histories never cross connections.