mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2322] [Issue]: Agent tool-call errors abort the whole agent run instead of being fed back to the model for self-correction #1149
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#1149
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 @Romuromylus on GitHub (Jun 5, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2322
Originally assigned to: @Romuromylus on GitHub.
Summary
Severity: Medium — Correctness / robustness. When a tool-using agent (Spotify DJ, haptic, or any custom-tool agent) makes a tool call with missing/invalid arguments, the agent tool loop re-throws the error and aborts the entire agent run, producing no usable output for the turn. The model is never given the error to self-correct. This is asymmetric with the rest of the codebase, which feeds tool errors back to the model.
Expected behavior
A tool-call error should be captured and returned to the model as a
role:"tool"result withsuccess:false, so the model can retry/recover within the remaining tool rounds — exactly as the main-character tool loop already does.Actual behavior
src/engine/agents-runtime/executor/agent-executor.ts:372-378, insideexecuteAgentWithTools' per-tool-call loop:The re-throw unwinds the round loop and is caught only by
executeAgent's outer try (catch at 279-281), returningmakeError(...).executeBuiltInTool(tools-runtime.ts:331) callstoolError()(throw new Error(message)) for every missing required arg —roll_dice/notation,update_game_state/type+target+key,search_lorebook/query,spotify_play/uri|uris,write_chat_variable/key, etc. — andexecuteToolCallroutes built-ins straight there with no try/catch.This is asymmetric: the main-character tool loop (
start-generation.ts:3426-3448) catches the throw, setssuccess=false, and pushes the error back as the tool result; the Spotify playback fallback (agent-executor.ts:562-570) likewise returns a structured error. Only the agent tool loop hard-aborts.Steps to reproduce
chat.metadata.enableTools) with a tool-using agent active (e.g. Spotify DJ).executeBuiltInTool→toolError()throws; the whole agent run aborts withmakeError, wasting the turn.Impact area
Environment
b0e5561dLogs, screenshots, or video
Static source audit; cited to file:line above.
Regression notes
Found via static audit of the refactor branch; not verified against main. Gated behind opt-in
enableTools+ an active tool-using agent; blast radius is one wasted agent turn (recoverable next turn), hence medium.Additional context
Suggested fix: in the catch at line 375, do not re-throw on tool errors — capture
extractErrorMessage(err), emit a tool-resultsuccess:false, and pushrole:"tool"contentstringifyToolResult({ error: ... })withtool_call_id: tc.idso the model can retry withinMAX_TOOL_ROUNDS. Re-throw only onAbortSignalcancellation, mirroringstart-generation.ts:3426-3448.Template check
Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked:
@Romuromylus commented on GitHub (Jun 6, 2026):
Fixed by #2397, merged into
refactor.