If you've ever built an AI agent using function calling (tool use), you probably know the exact feeling of pure panic. You test your agent, it seems fine, you go grab a coffee, and come back to see it got stuck in an infinite loop—calling the exact same tool, failing, and retrying 500 times. Suddenly, your OpenAI API balance is completely drained. 💸
After burning my own credits one too many times, I decided enough was enough. I built PromptShark—an open-source MITM proxy designed specifically to catch these loops, save your wallet, and make debugging agents painless.
PromptShark is a drop-in local proxy that sits between your code and the LLM provider. The best part? Zero code changes required.
You don't need to rewrite your agent or install heavy SDKs. Just change your base_url
to http://localhost:8080/v1
and keep your API key as is. PromptShark intercepts the traffic and does the magic.
Here are the main features:
PromptShark tracks your agent's sessions and hashes the request payloads. If it detects that your agent is stuck in a repetitive loop (e.g., repeatedly passing the exact same wrong arguments to a tool and failing), it instantly blocks the request before it hits the OpenAI API. No more burned money.
Debugging multi-step agents is expensive because when it fails at step 10, you usually have to restart and pay for steps 1-9 all over again.
PromptShark caches the session locally in SQLite. If your agent makes a mistake, you can:
It comes with a clean, dark-mode UI where you can track Time-To-First-Token (TTFT), monitor token usage (prompt vs. completion tokens separated per step), and see your exact cost in USD in real-time.
I wanted this tool to be fast, reliable, and easy to run locally:
You can spin it up right now using Docker Compose.
If you are building AI agents and are tired of losing API credits to rogue tool calls, I’d love for you to try it out.
🔗 **GitHub Repository:** [apvcode/PromptShark](https://github.com/apvcode/PromptShark)