singularity-forge/packages/pi-ai/src
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
..
providers fix: repair YAML bullet lists in malformed tool-call JSON (#3090) 2026-03-30 14:37:09 -06:00
utils fix(pi-ai): extend repairToolJson to handle XML tags and truncated numbers 2026-04-04 03:59:55 -07:00
api-registry.ts refactor: remove dead code (unused exports) (#1486) 2026-03-19 15:33:32 -06:00
bedrock-provider.ts feat: vendor Pi source into workspace monorepo 2026-03-12 21:55:17 -06:00
cli.ts feat: vendor Pi source into workspace monorepo 2026-03-12 21:55:17 -06:00
env-api-keys.ts feat(extensions): add Ollama extension for first-class local LLM support (#3371) 2026-04-01 08:37:31 -06:00
index.ts fix: repair YAML bullet lists in malformed tool-call JSON (#3090) 2026-03-30 14:37:09 -06:00
models.custom.ts feat(models): add GLM-5.1 to Z.AI provider in custom models 2026-03-27 14:49:43 -06:00
models.generated.ts fix(pi-ai): correct Copilot context window and output token limits (#2118) 2026-03-22 17:04:16 -06:00
models.test.ts test(models): add GLM-5.1 custom model tests 2026-03-27 16:48:11 -06:00
models.ts refactor(pi-ai): replace model-ID pattern matching with capability metadata (#2548) 2026-03-26 16:38:29 -06:00
oauth.ts feat: vendor Pi source into workspace monorepo 2026-03-12 21:55:17 -06:00
stream.ts feat: vendor Pi source into workspace monorepo 2026-03-12 21:55:17 -06:00
types.ts feat(extensions): add Ollama extension for first-class local LLM support (#3371) 2026-04-01 08:37:31 -06:00
web-runtime-env-api-keys.ts feat(web): browser-based web interface (#1717) 2026-03-21 12:16:54 -06:00
web-runtime-oauth.ts feat(web): browser-based web interface (#1717) 2026-03-21 12:16:54 -06:00