Add autofix extension for malformed JSON tool calls#1
Draft
clebreto wants to merge 1 commit intoben-vargas:mainfrom
Draft
Add autofix extension for malformed JSON tool calls#1clebreto wants to merge 1 commit intoben-vargas:mainfrom
clebreto wants to merge 1 commit intoben-vargas:mainfrom
Conversation
693c40e to
81934ba
Compare
This extension provides automatic fixing of malformed JSON tool calls
using the Synthetic fix-json model.
Features:
- Intercepts tool call JSON parsing via onToolCallParse hook
- Fixes malformed JSON using hf:syntheticlab/fix-json
- Shows "Fixing JSON for {toolName}..." in working message during fix
- Includes /test-autofix command for testing
Setup:
export SYNTHETIC_API_KEY="syn_..."
pi -e ./extensions/autofix.ts
Configuration:
PI_AUTOFIX_ENABLED - Enable/disable (default: true)
PI_AUTOFIX_MODEL - Fix model (default: hf:syntheticlab/fix-json)
PI_AUTOFIX_BASE_URL - API endpoint
Requires pi with hook-based tool parsing support.
Related: PR feature/hook-based-tool-parsing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Autofix Extension for Malformed JSON
Automatically fixes broken JSON in tool calls using Synthetic's
hf:syntheticlab/fix-jsonmodel.Why?
Some models generate malformed JSON (missing quotes, trailing commas, etc). This extension catches those errors and fixes them automatically, so tool calls don't fail.
Quick Start
Then use
/test-autofixto try it out.How It Works
Uses the new
onToolCallParsehook from https://github.com/clebreto/pi-mono/pull/feature/hook-based-tool-parsing:Config
PI_AUTOFIX_ENABLED- turn on/off (default: true)PI_AUTOFIX_MODEL- which model to use (default: hf:syntheticlab/fix-json)SYNTHETIC_API_KEY- your API keyFiles Changed
extensions/autofix.ts(new) - the extensionpackage.json- register the extensionIT MUST REMAIN IN DRAFT SO LONG THE PR IN PI-MONO IS NOT MERGED.