{"slug": "i-built-promptshark-in-one-evening-to-stop-my-ai-agents-from-burning-money-on", "title": "I Built PromptShark in One Evening to Stop My AI Agents from Burning Money on Infinite Loops", "summary": "A developer built PromptShark, an open-source MITM proxy that prevents AI agents from burning API credits on infinite loops. The tool sits between code and LLM providers, detects repetitive tool-call failures, and blocks requests before they reach the API. It also caches sessions locally and provides a UI for monitoring token usage and costs.", "body_md": "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.\n\nSuddenly, your OpenAI API balance is completely drained. 💸\n\nAfter 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.\n\nPromptShark is a drop-in local proxy that sits between your code and the LLM provider. The best part? **Zero code changes required.**\n\nYou don't need to rewrite your agent or install heavy SDKs. Just change your `base_url`\n\nto `http://localhost:8080/v1`\n\nand keep your API key as is. PromptShark intercepts the traffic and does the magic.\n\nHere are the main features:\n\nPromptShark 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.\n\nDebugging 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.\n\nPromptShark caches the session locally in SQLite. If your agent makes a mistake, you can:\n\nIt 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.\n\nI wanted this tool to be fast, reliable, and easy to run locally:\n\nYou can spin it up right now using Docker Compose.\n\nIf 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.\n\n🔗 **GitHub Repository:** [apvcode/PromptShark](https://github.com/apvcode/PromptShark)", "url": "https://wpnews.pro/news/i-built-promptshark-in-one-evening-to-stop-my-ai-agents-from-burning-money-on", "canonical_source": "https://dev.to/apvcode/i-built-promptshark-in-one-evening-to-stop-my-ai-agents-from-burning-money-on-infinite-loops-7ok", "published_at": "2026-06-17 09:38:38+00:00", "updated_at": "2026-06-17 09:51:12.953121+00:00", "lang": "en", "topics": ["ai-agents", "developer-tools", "large-language-models"], "entities": ["PromptShark", "OpenAI", "SQLite", "Docker"], "alternates": {"html": "https://wpnews.pro/news/i-built-promptshark-in-one-evening-to-stop-my-ai-agents-from-burning-money-on", "markdown": "https://wpnews.pro/news/i-built-promptshark-in-one-evening-to-stop-my-ai-agents-from-burning-money-on.md", "text": "https://wpnews.pro/news/i-built-promptshark-in-one-evening-to-stop-my-ai-agents-from-burning-money-on.txt", "jsonld": "https://wpnews.pro/news/i-built-promptshark-in-one-evening-to-stop-my-ai-agents-from-burning-money-on.jsonld"}}