mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #3007] [Issue]: Custom tool with empty {} parametersSchema (the schema default) is silently dropped from generation #1579
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#1579
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/3007
Originally assigned to: @SpicyMarinara on GitHub.
What's wrong
validateToolSchemarejects a schema that has neither a roottypenorproperties. The Zod schema for custom tools defaultsparametersSchemato{}when the field is omitted. A custom tool stored withparametersSchema = {}therefore fails validation inloadToolDefinitions, is caught, logged only as a serverwarn, and silently skipped — so the tool never reaches the model even though it shows as enabled. This is the legitimate "tool takes no parameters" case, which the client UI handles fine (it emits{ type: "object", properties: {}, required: [] }). The result is an inconsistency: a no-parameter tool created in the UI works, but the same tool created via the REST API (omittingparametersSchema) or imported from a package lacking a schema is silently non-functional.How to reproduce (try it yourself)
POST /custom-toolswith a body that omitsparametersSchema, e.g.{ "name": "get_time", "description": "...", "executionType": "static", "staticResult": "now" }. Zod applies.default({})and the tool is stored withparametersSchema = "{}". (Or import a tool package whose source has no/invalid parametersSchema.)enableTools=true).You'll see:
validateToolSchema({})throws, the catch block deletes the registration and logs awarn, and the tool is omitted from the definitions sent to the model. The model never sees the tool and there is no user-facing error.Expected: a zero-parameter custom tool is offered to the model regardless of whether it was created via UI, REST, or import.
Where it is
packages/server/src/services/generation/tool-resolution-runtime.ts: the throwing branch invalidateToolSchemaat lines 249-251, and the silentloadToolDefinitionscatch at lines 329-337. The default originates atpackages/shared/src/schemas/custom-tool.schema.ts:15(parametersSchema: z.record(z.unknown()).default({})) and is persisted unnormalized atpackages/server/src/services/storage/custom-tools.storage.ts:42. The contrasting UI emitter ispackages/client/src/components/agents/ToolEditor.tsx:140-149.What's happening
validateToolSchematreats a schema with notypeand nopropertiesas invalid, but the persisted default for a parameter-less custom tool is exactly{}. The create route accepts{}without normalizing it to{ type: "object", properties: {} }, so the empty object survives to generation time where it is rejected and the tool dropped.Suggested fix
In
tool-resolution-runtime.ts, replace the throwing branch invalidateToolSchema(lines 249-251) with in-place normalization so a parameter-less tool is treated as a zero-parameter object schema:Leave the rest of the function unchanged so the earlier guards and the trailing
requiredcheck still run and the now-normalizedschemaObjectis returned. This single generation-time fix covers newly-created REST tools, already-stored{}rows, imported packages lacking a schema, and the Zod/DB{}default in one place, matching the canonical{ type: "object", properties: {} }shape the UI and built-in tools already emit.Regression avoided: the fix normalizes the missing
type/propertieskeys in place and falls through to the existingrequiredcheck rather than early-returning a fresh{type:"object",properties:{}}object — so it neither skips therequiredvalidation nor discards other already-present valid keys (e.g. a schema carrying{required:[...]}but notype). The alternative "normalize at create/update time" was rejected as incomplete: it would not fix rows already persisted with{}.Related: this touches the same
validateToolSchemafunction as the nested-property-validation gap (filed as a sibling issue). Coordinate the two — this one relaxes the empty-{}case; the other adds nested validation.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 #3018.