pi-tool-repair 0.1.6 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-tool-repair",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "Validate-then-repair extension for pi — fixes common LLM tool-call mistakes (null fields, stringified arrays, wrong field names, anchor bleed) before tools execute",
5
5
  "type": "module",
6
6
  "author": "Tom X Nguyen",
@@ -156,6 +156,21 @@ export function repairAssistantMessageGrammarLeaks(
156
156
  changed = true;
157
157
  for (const candidate of candidates) {
158
158
  if (candidate.stripOnly) continue;
159
+
160
+ // Safety: don't recover tool calls whose grammar parsed to an empty
161
+ // argument object. These are almost always malformed GLM/XML fragments
162
+ // (e.g. `<tool_call>write</tool_call>`) that would otherwise crash as a
163
+ // real tool invocation with missing required properties.
164
+ if (Object.keys(candidate.arguments).length === 0) {
165
+ if (config.debug) {
166
+ process.stderr.write(
167
+ `[pi-tool-repair] grammar-repair skipping ${candidate.grammar}:${candidate.name} ` +
168
+ "(empty arguments, likely malformed grammar)\n",
169
+ );
170
+ }
171
+ continue;
172
+ }
173
+
159
174
  recoveredCalls.push({
160
175
  name: candidate.name,
161
176
  arguments: candidate.arguments,