mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #188] [CLOSED] universal agent tool support #4498
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#4498
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?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/188
Author: @adunato
Created: 4/22/2026
Status: ❌ Closed
Base:
main← Head:upstream-main📝 Commits (10+)
75f5196docs: init HLD and implementation plan for CR001 chat_summary_toolsaa058abfeat: implement read_chat_summary and append_chat_summary built-in tools8bb7adddocs: init HLD and implementation plan for CR002 universal_agent_tool_support2576ef2feat: relocate and generalize agent tool resolutionb20a9a0feat: add debug logging for agent tool calls and resultsbc57719feat: improve agent-pipeline logging to show both batchable and tool-using agent names01eca24local: update gitignore for dev scripts4044cccMerge branch 'change/CR001-chat_summary_tools'75629e6Merge branch 'change/CR002-universal_agent_tool_support'c551479local: clean up draft design file📊 Changes
9 files changed (+293 additions, -62 deletions)
View changed files
➕
change_requests/CR001_chat_summary_tools/HLD.md(+15 -0)➕
change_requests/CR001_chat_summary_tools/IMPLEMENTATION_PLAN.md(+25 -0)📝
packages/server/src/routes/generate.routes.ts(+171 -61)📝
packages/server/src/services/agents/agent-executor.ts(+2 -0)📝
packages/server/src/services/agents/agent-pipeline.ts(+1 -1)📝
packages/server/src/services/tools/tool-executor.ts(+53 -0)📝
packages/shared/src/types/agent.ts(+24 -0)➕
start_dev_client.bat(+1 -0)➕
start_dev_server.bat(+1 -0)📄 Description
Why this change
Problem Statement:
Currently, the generation pipeline in the Marinara Engine contains a hardcoded restriction that only allows the
spotify agent to utilize function calling (tools). For all other agents—built-in or custom—the server ignores their
enabledTools configuration and sends them into the pipeline as "batchable" (text-only) agents. This prevents users
from extending the engine's capabilities via custom agent-tool interactions.
Solution:
This PR generalizes the tool resolution logic within the generate route. It relocates tool definition and Spotify
credential resolution to the beginning of the pipeline and iterates through all agents. For every agent with tools
enabled in its settings, the server now correctly attaches a toolContext, enabling true function-calling capabilities
for both custom and built-in agents.
What changed
Key Changes
project conventions.
Validation
pnpm checkManual verification notes
Verification Performed
Prerequisites: Test Agent enabled with instruction to invoke roll_dice tool (tool enabled in test agent configuration), tools enabled in chat.
Orchestration Test: Confirmed via server logs that a custom agent now reports as 1 tool-using instead of 1
batchable.
Functionality Test: Verified that a custom agent can successfully call the roll_dice tool, receive the JSON result,
and incorporate it into its final response.
Logging Test: Verified that the new [agent-tools] logs correctly display the function name, arguments, and raw
results in the terminal.
Cross-check: compared before / after change server logging with the same test to demonstrate tool calling behaviour (before:[agent-pipeline] executeGroup: 1 batchable, 0 tool-using [ 'custom-test-agent' ]. after: [agent-pipeline] executeGroup: 0 batchable, 1 tool-using []
OUT of scope of validation: existing tools. The only agent that seem to be enabled for tools and has tools in its prompt is "Spotify DJ", the others either don't have tools enabled and/or do not mention tools in their prompt.
Merge recommendations: regression testing on Spotify DJ agent, as I was unable to test it.
Docs and release impact
UI evidence (Not applicable)
Additional Information
Logging Information
Prior to the change:
[generate] chatId=Dwlm4t37BhFxx6sPbpB31, chatMode=roleplay
[timing] Embedding: 2ms
[generate] Resolved 1 agents for chat Dwlm4t37BhFxx6sPbpB31 (enableAgents=true, perChatList=true, activeIds=[custom-test-agent]) [ 'custom-test-agent(pre_generation)' ]
[timing] Prompt assembly + context: 49ms
[agent-pipeline] Phase "pre_generation": 1 agents → 1 group(s) [ '[custom-test-agent] (model: z-ai/glm-5.1)' ]
[agent-pipeline] executeGroup: 1 batchable, 0 tool-using [ 'custom-test-agent' ]
[agent-batch] Only 1 agent (custom-test-agent), running individually
[agent] custom-test-agent (Test Agent) — z-ai/glm-5.1
[OpenAI chatComplete()] stream=true model=z-ai/glm-5.1 onToken=true
[agent] custom-test-agent done (14 chars, 1565ms)
[timing] Pre-gen agents: 1567ms
After the change:
[generate] chatId=Dwlm4t37BhFxx6sPbpB31, chatMode=roleplay
[timing] Embedding: 3ms
[generate] Resolved 1 agents for chat Dwlm4t37BhFxx6sPbpB31 (enableAgents=true, perChatList=true, activeIds=[custom-test-agent]) [ 'custom-test-agent(pre_generation)' ]
[timing] Prompt assembly + context: 49ms
[agent-pipeline] Phase "pre_generation": 1 agents → 1 group(s) [ '[custom-test-agent] (model: z-ai/glm-5.1)' ]
[agent-pipeline] executeGroup: 0 batchable, 1 tool-using [ 'custom-test-agent' ]
[OpenAI chatComplete()] stream=true model=z-ai/glm-5.1 onToken=false
[agent-tools] custom-test-agent calling: roll_dice({"notation": "1d6", "reason": "General dice roll"})
[agent-tools] custom-test-agent result: {"notation":"1d6","rolls":[5],"sum":5,"modifier":0,"total":5,"reason":"General dice roll","display":"🎲 1d6 (General dice roll): [5] = 5"}
[OpenAI chatComplete()] stream=true model=z-ai/glm-5.1 onToken=false
Detailed Code Changes
the agent pipeline is created.
attaches a toolContext (containing those definitions and an executeToolCall function) directly to the agent.
during their turn, rather than just generating static text.
Preserving Existing Spotify Token Logic
While generalizing the tool context, the specific token refresh logic required for the Spotify integration was
carefully decoupled. It still runs early to refresh the access token if needed, and injects those spotifyCreds into
the execution context so the Spotify tool can still authenticate properly when called by an agent.
Enhanced Pipeline Debugging & Visibility
The changes introduce specific console.log statements in the agent logic to improve observability:
"batchable" (text only) vs which are "tool-using" (capable of multi-step function calling).
arguments [agent-tools] <agent_type> calling: <func_name>().
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.