PromptShark is a transparent local proxy, loop detector, and debugging tool for AI agents. The project is built with Go and C++, uses the MIT license, and the repository address is https://github.com/apvcode/PromptShark。它的定位是解决智能体在无限工具调用循环中持续消耗 token issue, with the slogan "Intercept every prompt. Catch every loop. Replay any step.".
In terms of purpose, PromptShark sits between AI agents and the OpenAI API, intercepts every API call, records and visualizes every request/response pair, and automatically detects whether an agent is stuck in an infinite tool-calling loop. It emphasizes "one-line integration, zero code changes": simply replace the agent's base_url with http://localhost:8080/v1 to connect.
Main capabilities include:
- Interception and inspection: every API call flows through PromptShark, allowing you to view structured request/response pairs, collapse raw JSON payloads, and track token usage by step, with a Prompt / Completion breakdown.
- Loop detection: a dedicated C++ engine runs in parallel with the Go proxy via IPC, hashes each tool call, and instantly flags repeated patterns, issuing alerts before API balance is exhausted.
- Time-travel replay: click any historical step, edit the JSON payload in the built-in editor, preview changes through an interactive diff view, and rerun the agent from that point; earlier steps are served from the SQLite cache with no additional API cost.
- Real-time dashboard: a dark glassmorphism UI, powered by WebSocket for real-time streaming, supports automatic session switching, instant step search, Markdown export, and session management, all integrated into a single embedded HTML page.
Usage provides three run options:
- Option A: Docker (recommended).
- Option B: Precompiled binaries. Download the latest .zip or .tar.gz for the corresponding operating system (Windows, macOS, Linux) from the GitHub Releases page, extract it, and run agent_supervisor (or agent_supervisor.exe).
- Option C: Build from source. First build the C++ core, then run the proxy, then open http://localhost:8080,仪表盘即准备就绪,最后将智能体指向该地址。
For configuration, edit loop_config.txt in the project root directory to configure the loop detector; environment variables PORT and DB_PATH are also supported (command-line flags take precedence). The server supports graceful shutdown: after pressing Ctrl+C, it completes in-progress requests, closes the database, and exits cleanly (the original text shows the output ✅ Goodbye!).
Applicable scenarios: developers who need to debug AI agent API calls, troubleshoot infinite tool-calling loops, analyze token consumption, replay and edit failed steps and rerun them, and manage multiple agent sessions.
Limitations and missing facts: based on the available information, no specific pricing method, price, minimum runtime environment requirements, or performance metric data are provided. The project's mentioned future plans include: configuring loop rules via YAML (regex patterns, token budgets), supporting Ollama / Anthropic Claude API, and multi-agent message flow visualization (network graph); these are marked in the information as capabilities to be implemented.