Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
feat(session): include user_id and total_cost_usd in trajectory dump
#22
by GuillaumeSalouHF HF Staff - opened
Mirror of huggingface/ml-intern#136 applied surgically to the Space main (cherry-picking the upstream merge would pull in unrelated drift between github/main and the Space main).
Summary
Add user_id (HF username from OAuth, already on AgentSession) to the Session object and propagate into the trajectory JSON. Also surface a total_cost_usd aggregate summed from existing llm_call events.
Why
Today the session dataset has session_id but no user binding, so spend per HF user cannot be derived from the dataset alone. With user_id in the dump, per-user spend analysis becomes a one-liner over the dataset.
Changes
agent/core/session.py:Session.__init__acceptsuser_id;get_trajectory()includesuser_idandtotal_cost_usdbackend/session_manager.py: passuser_id=user_idwhen constructingSession
Total diff: 2 files, +13 / -1.
GuillaumeSalouHF changed pull request status to open
GuillaumeSalouHF changed pull request status to merged