惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

U
Unit 42
F
Fortinet All Blogs
Martin Fowler
Martin Fowler
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
IT之家
IT之家
Blog — PlanetScale
Blog — PlanetScale
罗磊的独立博客
V
V2EX
Vercel News
Vercel News
Apple Machine Learning Research
Apple Machine Learning Research
J
Java Code Geeks
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
T
Tailwind CSS Blog
I
InfoQ
Engineering at Meta
Engineering at Meta
WordPress大学
WordPress大学
S
SegmentFault 最新的问题
H
Help Net Security
腾讯CDC
D
Docker
P
Proofpoint News Feed
GbyAI
GbyAI
博客园 - 三生石上(FineUI控件)
aimingoo的专栏
aimingoo的专栏

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
I Built PromptShark in One Evening to Stop My AI Agents f...
Apvcode · 2026-06-17 · via DEV Community

Apvcode

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.

🦈 What is PromptShark?

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:

1. 🛑 Infinite Loop Detection

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.

2. ⏪ Time-Travel Replay & Caching (The Killer Feature)

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:

  • Go to the UI and rewind the session.
  • Edit the JSON payload (tweak the prompt or fake a tool response).
  • Resume the execution. Steps 1-9 will be instantly served from the cache for free, and the API will only be called for step 10.

3. 📊 Real-time Dashboard

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.

🛠️ Under the Hood

I wanted this tool to be fast, reliable, and easy to run locally:

  • Go handles the proxying, streaming, and WebSockets (perfect for network IO).
  • C++ Engine powers the fuzzy loop-detection logic via IPC.
  • SQLite (WAL mode) ensures blazingly fast caching without needing to spin up Postgres.

Try it out!

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