Repository navigation
Conversation
pi 1.5.0 validates tool arguments with @earendil-works/pi-schema, which coerces loosely typed values before validation: a required string sent as null becomes "null", and a required array of numbers sent as null becomes [0]. ctx_note and ctx_memory then store or look up garbage instead of rejecting the call.
Add prepareArguments to both tools; it runs before validation and before execute(), so it still sees the raw value. Reject only a raw null for content and a non-array ids. Tighten ctx_memory.ids to Type.Integer({ minimum: 1 }), matching ctx_note.note_ids. The literal string "null" stays accepted.
|
#843 has the |
|
The design is approved (issue 843 now has the |
|
Thanks for the update. The
With those changes the golden tests pass unchanged, and I'll merge once CI is green. |
Refs #843 (kept draft until the issue carries
design-approved).Harness coverage (required)
nullbefore the handler; no change needed.prepareArgumentsadded toctx_noteandctx_memory; tests added for both.pi-plugintool definitions and hook.What
pi 1.5.0 validates tool arguments with
@earendil-works/pi-schema, which coerces loosely typed arguments before validation. For required properties,nullis not dropped: a string schema receives"null"and an array schema receives[null], whose number items become0. As a result:ctx_notewithcontent: nullwrites the literal text"null"as the note body.ctx_memorywithcontent: nullwrites the literal text"null"as the memory body.ctx_memorywithids: nullbecomes[0];getreturns nothing instead of rejecting, andupdate/archivelook up id 0.This change adds
ToolDefinition.prepareArgumentsto both tools. The hook runs before schema validation and beforeexecute(), so it still sees the raw argument:content === nullin both tools;idswhen it is present and not an array;"null"unchanged.It also tightens
ctx_memory.idsfromType.Array(Type.Number())toType.Array(Type.Integer({ minimum: 1 })), matchingctx_note.note_ids; memory ids start at 1.Testing
The new tests were also run without the source change: exactly the nine new cases fail, so they cover the regression rather than merely passing.
Summary by cubic
Fixes pi 1.5.0's
@earendil-works/pi-schemacoercion mangling tool arguments inctx_noteandctx_memory.content: nullwas written as the literal text"null",ids: nullbecame[0]soget/update/archivetargeted id 0, and fractional ids like1.5could be truncated into the integer that modified the wrong record.prepareArgumentsto both tools, which runs before schema validation andexecute()and rejects any non-stringcontentand non-arrayids; the literal string"null"remains accepted.minimum: 1toctx_memory.ids, matching memory ids starting at 1.Written for commit bd9edf8. Summary will update on new commits.