feat(session): include user_id and total_cost_usd in trajectory dump

#22
by GuillaumeSalouHF HF Staff - opened
smolagents org

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__ accepts user_id; get_trajectory() includes user_id and total_cost_usd
  • backend/session_manager.py: pass user_id=user_id when constructing Session

Total diff: 2 files, +13 / -1.

GuillaumeSalouHF changed pull request status to open
GuillaumeSalouHF changed pull request status to merged

Sign up or log in to comment