r/MachineLearning · · 2 min read

[P]Stop using print() to debug your agents. Here's a 60-second alternative.[P]

Mirrored from r/MachineLearning for archival readability. Support the source by reading on the original site.

[P]Stop using print() to debug your agents. Here's a 60-second alternative.[P]

Hello,

If you have ever used multistep agents, RAG pipelines, or chained multiple LLM calls, there is one pain point you will all relate to. When an agent gets stuck in an infinite loop, suddenly hallucinates on the third step, or is quietly burning through OpenAI API credits... tracing exactly where the problem originated is a real nightmare.

Usually, you end up compromising on one of the following two methods:

Placing dozens of console.log or print() statements all over your once-clean code.

Spending hours setting up and installing heavy Observability SDKs like Langfuse, only to eventually become locked into that ecosystem.

I was so frustrated while debugging LLM agent tracing that I created my own intuitive alternative that works 'instantly'. The key is simply replacing the baseURL.

60-Second Solution:

You do not need to modify the core logic of your code or install heavy libraries. Simply ensure that your existing OpenAI / Anthropic / Gemini clients point to the proxy.

https://preview.redd.it/dlgok064fa5h1.png?width=2880&format=png&auto=webp&s=b0ae67b736c03c754ee26fd439b4858da626f69b

Literally, changing just a single line of code automatically applies the following features:

Parent-Child Agent Tracing: Visually debug exactly which stage of a multi-step workflow crashed or where bottlenecks (latency) occurred.

Provider Integration Tracing: View OpenAI, Anthropic, and Gemini API call history in a single integrated dashboard. Perfect for teams using multiple LLMs.

Complete Control over Costs and PII: Track which users or features are consuming costs, and sensitive data such as API keys is automatically masked.

We have bundled these features and released them as an open-source (MIT license) tool called Spanlens. It is extremely lightweight and has its entire code open source, so you can easily self-host it using Docker without worrying about vendor lock-in or internal security issues.

If you are tired of messy log debugging and the unpredictable LLM API charges that arrive at the end of every month, please check out the GitHub repository.

https://github.com/spanlens/Spanlens

I would be very grateful if you could feel free to give me feedback on what tools you are currently using to track complex LLM workflows, and if you have any suggestions for Spanlens after trying it out!

This isn't a commercial promotion, just try it for free. I want feedback.

submitted by /u/Limp_Shine8489
[link] [comments]

Discussion (0)

Sign in to join the discussion. Free account, 30 seconds — email code or GitHub.

Sign in →

No comments yet. Sign in and be the first to say something.

More from r/MachineLearning