Repository navigation
Description
Hi team,
I’m using hud-python and noticed that my runs on hud.ai → Traces are leaving behind many “live” sessions that don’t appear to terminate properly. These live sessions:
Continue to incur billing while they are shown as “live”.
Seem to count toward some API / usage limit (I started hitting limits much earlier than expected).
Cannot be easily terminated from the UI or from my Python code (at least I couldn’t find a documented way).
What I’m seeing
On hud.ai, under Traces (or equivalent), I see many traces/sessions in a “live” state.
These sessions were started from Python scripts / notebooks using hud-python.
In many cases the Python process crashed, was interrupted (e.g., Ctrl+C), or the environment was restarted (e.g., Jupyter / VSCode), and the corresponding live sessions never auto-close.
Over time, the number of live sessions keeps growing, and billing/usage keeps increasing.
Questions
How can I explicitly terminate/close a live session from hud-python?
Is there a method like client.close(), session.close(), or an API to cancel/finish a trace/run?
Is there a recommended pattern (e.g., context manager / with block, try/finally) to make sure a session is always closed even if the script crashes?
Is there a way to bulk-terminate these live sessions from the UI or API?
Right now I only see them accumulating in the HUD UI and I don’t see an obvious “terminate all live sessions” button.
Could these live sessions be contributing to hitting API limits earlier?
It looks like my account is hitting some API/usage limits faster than expected, and I suspect the stuck live sessions might be part of that.
Could you add documentation / examples for proper session lifecycle management?
For example, a short snippet like:
with hud.Session(...) as session:
# do work
session automatically closed here
Or explicit calls to end/terminate a session when the work is done.
Environment
hud-python version: x.y.z (please fill in)
Python version: 3.x
OS: Linux / macOS / Windows (please fill in)
How I run it: Jupyter notebook / VSCode / CLI script / …
Minimal example (sketch)
Roughly, I’m doing something like:
from hud import HudClient
client = HudClient(api_key="...")
repeated multiple times, sometimes crashing or being interrupted
for _ in range(10):
# create some run / trace / session
run = client.run("my_experiment")
# do some work…
# script may be interrupted or crash here
After a number of iterations, I see many “live” sessions still present in the hud.ai UI and being billed, even though there is no active Python process.
It would be super helpful to know:
the intended way to close/terminate a session from hud-python, and
whether there’s any cleanup / TTL / auto-expiration mechanism for abandoned live sessions.
Thanks a lot!
Activity
Parth220 commentedon Nov 27, 2025
Hi @Charlie-ZHIJIE!
Can you share which hud version you're on?
hud --versionIf you're not on the latest version, I'd suggest doing
uv tool upgrade hud-pythonAdditionally, all environments are automatically cleaned up in 3 hours of initialization.
We are considering doing an tool call/idle based expiration (close all environments without a tool call in the last ~15 minutes).
Environments should auto close on completion of a task, however there was an issue in some older version numbers what environment status updates were not propagated. You should have received a refund in hud credits on those traces.
Let me know if you have any questions and feel free to schedule some time if you'd like to chat!
https://cal.com/parth220/intro-chat-hud
MagellaX commentedon Dec 9, 2025
hey @Parth220 can we chat? would love to join the team though!! can you dm me on X!