r/PiCodingAgent • • 6h ago

Plugin Agent On-Demand; Use multiple local models without keeping them all loaded

Post image

I've been trying to utilize my local GPU with different local models, but I couldn't run them all at once and it was a pain to keep starting and stopping them manually.

I built Agent On-Demand, an open-source OhMyPi (OMP) extension that makes local models available as native providers and manages their inference engines automatically.

  • Configure multiple models and select them directly in OMP.
  • Assign different models to coding, reviewing, research, or the default roles.
  • Share a port to run models sequentially, or use different ports to run them concurrently if your hardware allows.
  • Automatically start the engine when needed and release its resources when the agent finishes.
  • Verify model identity and GPU execution without silent fallback to CPU-only or hosted inference.

Currently supports llama.cpp, tqLLM, Project Maya, and Strata, with qualified configurations documented in the README.

It's MIT-licensed and currently supports OMP 19.4.0 and 19.4.1 on Linux.

I originally built this to share GPU resources between local agents and ML research workloads, but figured others might find it useful.

Feedback and contributions are welcome!

https://github.com/davidandrewcope/agent-ondemand

I have not tested it in pi.dev, but I'm sure it could be modified to support it if anyone is interested.

0 Upvotes

6 comments sorted by

2

u/winky9827 5h ago

Were you unaware that llama-swap exists?

1

u/shaggydog97 5h ago

I was unaware, but this plugin is more tightly integrated into OMP. Agent On-Demand is specifically designed around OMP and integrates naturally into its agent selection capabilities. You can assign local models to "@tiny" or "@slow" for example and they will start on demand. Your local models show up in the normal model selection interface.

llama-swap seems very interesting, but seems to have a more broad use case than this.

1

u/winky9827 5h ago

models.json custom providers for llama-swap models, show up in the picker just fine:

https://i.imgur.com/dJ9dOkT.png

1

u/repolevedd 5h ago

Why is this designed to work specifically inside Pi, rather than at the API level like llama-swap? What's the advantage of doing it this way? I'm not quite sure how this solves the problem of allocating resources between tasks, especially when multiple programs are running, each in its own isolated sandbox, but there's only one GPU (for example).

1

u/shaggydog97 5h ago

I wanted a way to use more than one local model with OMP, but I could only start one at a time. It was annoying to start them manually. I'm also working on training an encoder model, so I had to take down my local models to test it. With this plugin, the main hosted agent can control my local agents and bring them up and down when needed.

1

u/repolevedd 5h ago edited 5h ago

Sorry, I still don't quite get it. Well, I understand that you need a way to load and unload models and start some GPU-demand processes, but why make it so complicated?

Here's how I see it. There are several layers:

  1. Applications and scripts that need GPU resources, whether for LLM inference or other ML workloads.
  2. An OpenAI-compatible API that applications use to send LLM requests.
  3. llama.cpp and other inference backends that actually run the models and compete for GPU resources.

The common integration point should be layer 2, the API, not one of the applications.

So why should I have to manage all of this manually when a single API endpoint could handle it for every application, loading and unloading models depending on which model a request is targeting? Layer 1 wouldn't need to know anything about what's happening behind the API, and layer 3 wouldn't have to compete for GPU resources because inference backends would be started and stopped on demand.

This way, any model could simply be selected in agent harnesses, LibreChat, or other applications, and everything would happen automatically based on incoming requests.

On top of that, if there's an ML script that also needs GPU resources, it could trigger a webhook to pause all LLM request queues, allowing the running inference processes to shut down and free up the GPU. The ML job could then run, and the queued LLM tasks could resume afterward. Alternatively, the API proxy could monitor system processes and free up the GPU when needed.

I'm not describing llama-swap specifically here, but rather the general idea of how this kind of orchestration could work. In principle, there shouldn't be any need for manual unload commands at all. Everything could be handled automatically without interfering with the agents' isolated sandboxes.

Your extension, on the other hand, looks like a very specialized tool for managing things only in OMP, without actually addressing the underlying problem of GPU resource allocation.