pi-meta-fix

Pi extension fix for Muse Spark compaction - strips illegal tool_choice values (only auto supported by api.meta.ai)

Packages

Package details

extension

Install pi-meta-fix from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:pi-meta-fix
Package
pi-meta-fix
Version
1.0.0
Published
Aug 25, 2026
Downloads
147/mo · 147/wk
Author
bakr-bagaber
License
MIT
Types
extension
Size
6.2 KB
Dependencies
0 dependencies · 1 peer
Pi manifest JSON
{
  "extensions": [
    "./extensions/meta-fix/index.ts"
  ]
}

Security note

Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.

README

pi-meta-fix

Pi extension fix for Muse Spark compaction failure on api.meta.ai.

Problem

Muse Spark (api.meta.ai/v1) only supports tool_choice: "auto". Pi's compaction (summarization) and some tool flows send tool_choice: "none", "required" or named function choices, causing:

Compaction failed: Summarization failed: 400: only "auto" is supported for tool_choice

Previous file-patch of pi-ai/dist doesn't work for the Windows compiled bun binary (pi-ai baked in).

Fix

This extension patches globalThis.fetch at startup inside the binary's runtime. Any request to api.meta.ai with illegal tool_choice is sanitized (deleted if != auto) before forwarding. Works for both providers:

  • meta/muse-spark-1.2-contributor (openai-completions)
  • meta-ai/muse-spark-1.1 (openai-responses via pi-meta-ai)

Compaction stays on Muse Spark - no model switch needed.

Install

pi install pi-meta-fix
# or
npm install -g pi-meta-fix
# then add to ~/.pi/agent/settings.json packages:
# { "source": "npm:pi-meta-fix" }

Or manual:

{
  "packages": [
    "npm:pi-meta-fix"
  ]
}

Restart pi after install.

Config

No config. Works out of the box. For 1M context window recommended:

{
  "models": {
    "providers": {
      "meta": {
        "models": [{
          "id": "muse-spark-1.2-contributor",
          "contextWindow": 1048576,
          "maxTokens": 64000
        }]
      }
    }
  },
  "compaction": {
    "enabled": true,
    "reserveTokens": 65536,
    "keepRecentTokens": 80000
  }
}

License

MIT