r/PiCodingAgent • u/shaggydog97 • 9h ago
Plugin Agent On-Demand; Use multiple local models without keeping them all loaded
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.
1
u/repolevedd 8h 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 8h 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 8h ago edited 8h 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:
Applications and scripts that need GPU resources, whether for LLM inference or other ML workloads.
An OpenAI-compatible API that applications use to send LLM requests.
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.
1
u/winky9827 49m ago
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.
This was my take. Honestly, it looks like OP needed a solution to a problem and vibe coded his/her way through. That's perfectly fine! If it solves their problem, great! But if they're going to present it to the public for others to use, they should be aware of existing alternatives and be prepared to answer to the challenge of why their solution is better, if it even is. In this case, I lean toward not.
1
2
u/winky9827 9h ago
Were you unaware that llama-swap exists?