@andriimartynov/pi-ollama-model-switcher

Monitors and manages Ollama model instances within the pi coding agent harness.

Package details

extension

Install @andriimartynov/pi-ollama-model-switcher from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:@andriimartynov/pi-ollama-model-switcher
Package
@andriimartynov/pi-ollama-model-switcher
Version
0.0.1
Published
May 2, 2026
Downloads
not available
Author
andriimartynov
License
MIT
Types
extension
Size
4.6 KB
Dependencies
0 dependencies · 1 peer
Pi manifest JSON
{
  "extensions": [
    "./index.ts"
  ]
}

Security note

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

README

Ollama Model Switcher Extension

Monitor and auto-manage Ollama model instances within the pi coding agent harness.

Description

This extension monitors changes in the selected language model. Its primary purpose is to automatically manage and stop a previously running Ollama model instance when a new model is selected, ensuring that system resources are released efficiently.

Security Note: This extension executes shell commands (ollama stop) in the background. Ensure your environment is appropriately configured to allow these operations.

Prerequisites

  • pi coding agent harness must be installed.
  • Ollama must be installed and running on your system.
  • The ollama CLI must be available in your system PATH.

Installation

From GitHub

pi install git:github.com/andriimartynov/pi-ollama-model-switcher

FROM LOCAL PATH (DEVELOPMENT)

pi install /path/to/pi-ollama-model-switcher

Features

  • Model Change Detection: Listens for the model_select event.
  • Ollama Management: If the selected model changes from a previous Ollama model, it safely stops the old instance.

How it Works

  1. Trigger: A user changes the selected model in the harness.
  2. Check: The extension verifies if the previously active model was an Ollama model.
  3. Action: If so, it executes ollama stop [previous_model_id] in the background.

This ensures that resources tied to the old instance are released before new operations continue.

Limitations

  • Ollama Only: It only manages cleanup for Ollama models; switching to/from non-Ollama models does not trigger cleanup.
  • Stop Only: This extension manages stopping existing processes; it does not handle starting new models.

Changelog

v0.0.1

  • Initial release.