mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #3005] [Issue]: ToolEditor silently strips rich parameter-schema fields (enum/items/min/max/oneOf) on open+save #1577
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#1577
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/3005
Originally assigned to: @SpicyMarinara on GitHub.
What's wrong
The Tool Editor seeds its parameter list from
dbTool.parametersSchemabut preserves only each property'stypeanddescription, then writes the schema back from that flattened model. Any other JSON-Schema keyword a parameter carries —enum,items(for array params),default,minimum,maximum,multipleOf, nested objectproperties, or schema-leveladditionalProperties/oneOf/rootdescription— is silently discarded the moment a user opens the tool and clicks Save (or Export). A custom tool imported with a rich parameter schema (imports preserve the full nested record, and the server stores it verbatim) is therefore destructively flattened to bare{type, description}properties just by being edited. The user cannot see this happening: the editor renders the params as if nothing is wrong, and Save succeeds. The tool's contract sent to the model is now weaker or invalid (e.g. an array param with noitems).How to reproduce (try it yourself)
{"type":"object","properties":{"unit":{"type":"string","enum":["c","f"]},"days":{"type":"array","items":{"type":"string"}}},"required":["unit"]}. The import path stores it verbatim in the DB.prop.type/prop.descriptioninto local params, droppingenum/items.You'll see: the
enum,items, and any numeric constraints are gone; properties are bare{type, description}.Expected: opening and saving a tool with a rich parameter schema is non-destructive — constraints round-trip unchanged.
Where it is
packages/client/src/components/agents/ToolEditor.tsx: the seed effect at lines 96-110 (maps each property to{name, type, description, required}, dropping all other keywords) andbuildParamsSchemaat lines 140-149 (reconstructs each property as only{type, description}). Destructive persist confirmed atpackages/server/src/services/storage/custom-tools.storage.ts:61(updateFields.parametersSchema = JSON.stringify(data.parametersSchema), no merge). The sharedToolParameterProperty/ToolParameterSchematypes (packages/shared/src/features/function-calls/tool-definitions.ts:8-27) explicitly support these keywords, andparametersSchemaisz.record(z.unknown())so rich schemas genuinely exist in the DB.What's happening
The editor models parameters as a lossy
ParamDef[]({name, type, description, required}) instead of round-tripping the full per-property schema and the root schema. Both the read (seed effect) and the write (buildParamsSchema) only knowtypeanddescription, so every other keyword is dropped on the round-trip, and the server overwrites the stored schema with the flattened result.Suggested fix
Round-trip the full per-property schema AND the full root schema instead of emitting bare
{type, description}objects.ParamDefwithraw?: Record<string, unknown>(the original per-property JSON-Schema), and addconst [rawSchema, setRawSchema] = useState<Record<string, unknown>>({});.setRawSchema(schema)) and each property's full object (raw: prop). ResetsetRawSchema({})in theisNewbranch alongsidesetLocalParams([]).buildParamsSchemato merge edits onto the preserved schemas and addrawSchemato its deps:raw(raw: undefined) so stale type-specific keywords (e.g.itemson a now-string param) are dropped.Regression avoided: the original suggested fix stashed only a per-property
rawand still rebuilt the root object from scratch — so schema-leveladditionalProperties/oneOf/rootdescription(which the runtime forwards verbatim to the provider) would still be lost. The corrected fix also preserves the root schema. It also clears cachedrawon a deliberate type change so the merge does not re-emit a keyword incompatible with the new type; an untouched open+save round-trips losslessly. No other tool type flows throughbuildParamsSchema, so static/webhook/script/built-in tools are unaffected.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.