singularity-forge/packages/pi-ai
Tibsfox 920fed7122 fix(pi-ai): extend repairToolJson to handle XML tags and truncated numbers
The existing repairToolJson only handles YAML bullet lists (#2660).
Two additional malformation patterns from smaller models now cause
tool call failures and stuck retry loops:

1. XML parameter tags mixed into JSON values (#3403):
   LLMs (especially Haiku-class) sometimes emit hybrid XML/JSON
   syntax like <parameter name="X">value</parameter> inside
   JSON string values. Add stripXmlParameterTags() to remove
   the tags while preserving content.

2. Truncated numeric values (#3464):
   Smaller models emit incomplete numbers like "exitCode": -,
   or "durationMs": , when values are cut off mid-generation.
   Add repairTruncatedNumbers() to replace these with 0.

Both repairs run before the existing YAML bullet repair phase.
The AJV validation layer (coerceTypes: true) then handles any
remaining string-to-number coercion.

Adds 13 new tests covering detection and repair for both patterns.

Closes #3464, closes #3403, addresses #3369
2026-04-04 03:59:55 -07:00
..
scripts fix(pi-ai): correct Copilot context window and output token limits (#2118) 2026-03-22 17:04:16 -06:00
src fix(pi-ai): extend repairToolJson to handle XML tags and truncated numbers 2026-04-04 03:59:55 -07:00
bedrock-provider.d.ts feat: vendor Pi source into workspace monorepo 2026-03-12 21:55:17 -06:00
bedrock-provider.js feat: vendor Pi source into workspace monorepo 2026-03-12 21:55:17 -06:00
oauth.d.ts fix: add missing package.json subpath exports and oauth stubs (#1014) 2026-03-17 18:01:56 -06:00
oauth.js fix: add missing package.json subpath exports and oauth stubs (#1014) 2026-03-17 18:01:56 -06:00
package.json feat: add anthropic-vertex provider for Claude on Vertex AI (#1533) 2026-03-19 23:14:13 -06:00
tsconfig.json feat: vendor Pi source into workspace monorepo 2026-03-12 21:55:17 -06:00