Auto-share session traces to a private HF dataset#193
Conversation
|
Claude finished @lewtun's task in 3m 18s —— View job PR Review: Auto-share session traces to a private HF datasetNo blocking issues — 3 P1 What I checked
P1 — Concurrent write race between org and personal uploaders
If the personal uploader reads the file before the org uploader finishes writing, the personal uploader's final The org Hub dataset receives spurious duplicate uploads; the Hub is content-hash idempotent so no data is corrupted, but the retry behavior is incorrect. P1 — Personal upload silently skipped when user authenticated via
|
|
Claude finished @lewtun's task in 2m 41s —— View job PR Review: Auto-share session traces to a private HF dataset
No blocking issues — 0 new findings What I checked
Re-review notesThe two new commits ( No new P0 findings were identified. |
Co-authored-by: Codex <codex@openai.com>
Co-authored-by: Codex <codex@openai.com>
|
Claude finished @lewtun's task in 2m 56s —— View job PR Review: Auto-share session traces to a private HF dataset
No new P0 findings What I checked
Re-review notesTwo new real-code commits since the last review (
The three P1 findings from the first review remain outstanding (concurrent write race, |
Co-authored-by: Codex <codex@openai.com>
|
Claude finished @lewtun's task in 3m 36s —— View job PR Review: Auto-share session traces to a private HF dataset
No new P0 findings What I checked
Re-review notesOne new real-code commit since the last review (
The three P1 findings from the first review (concurrent write race, |
| json.dump(data, f, indent=2) | ||
| return False | ||
|
|
||
| # Scrub secrets (HF tokens, API keys, etc.) from messages + events |
There was a problem hiding this comment.
Why was this removed? We should retain some best-effort scrubbing
Co-authored-by: OpenAI Codex <codex@openai.com>
|
Claude finished @lewtun's task in 7m 16s —— View job PR Review: Auto-share session traces to a private HF dataset
No new P0 findings What I checked
Re-review notes
Addressing @lewtun's comment (
|
Co-authored-by: OpenAI Codex <codex@openai.com>
|
Claude finished @lewtun's task in 1m 26s —— View job PR Review: Auto-share session traces to a private HF dataset
No new P0 findings What I checked
Re-review notesOne new real-code commit since the last review (
Two new tests verify end-to-end that HF, Anthropic, and GitHub secrets are replaced in both the row and claude_code output files. The dataset card README update accurately describes the automated scrubbing and appropriately qualifies the warning as "no comprehensive redaction" — this is a correct and honest description. The three P1 findings from the first review (concurrent write race, |
Co-authored-by: OpenAI Codex <codex@openai.com>
|
Claude finished @lewtun's task in 1m 8s —— View job PR Review: Auto-share session traces to a private HF dataset
No new P0 findings What I checked
Re-review notesOne new real-code commit since the last review (
The three P1 findings from the first review (concurrent write race, |
lewtun
left a comment
There was a problem hiding this comment.
Thanks a lot for the nice PR @DarshanCode2005 ! LGTM now with some fixes I pushed
|
Thanks @lewtun. Would it be alright if I emailed you for some career advice? |
Resolves #191
What
Every ml-intern session now gets uploaded to your own private Hugging Face
dataset (default
{hf_user}/ml-intern-traces) in the Claude Code JSONLformat that the HF Agent Trace Viewer
auto-detects. The dataset is created private. You can flip it to public
from inside the CLI.
The existing upload to
smolagents/ml-intern-sessionsis unchanged. Thatdataset still feeds the backend KPI scheduler.
Why
Users wanted a way to browse, share, and debug their own runs through the
HF trace viewer without exposing them publicly by default.
Changes
Config
agent/config.py: addedshare_traces: bool = Trueandpersonal_trace_repo_template: str = "{hf_user}/ml-intern-traces".configs/cli_agent_config.jsonandconfigs/frontend_agent_config.json:surface the same defaults.
Uploader
agent/core/session_uploader.py: rewrote the subprocess uploader.to_claude_code_jsonl(trajectory)converter. Maps litellm messagesto user / assistant / tool_use / tool_result blocks. Deterministic
SHA-1 UUIDs keyed by
session_id::role::idxso re-uploads keep theparent chain stable. System prompts are skipped.
--format {row, claude_code},--token-env,--private.upload_statusfor the org dataset and
personal_upload_statusfor the user repo,so a failure on one path does not clobber the other.
--token-envoverrides the org fallback chain(
HF_SESSION_UPLOAD_TOKEN,HF_TOKEN,HF_ADMIN_TOKEN). Thepersonal upload uses
HF_TOKENdirectly.privateis now passed intocreate_repoinstead of being hardcoded.Existing repos keep whatever visibility the user set.
Session wiring
agent/core/session.py:_personal_trace_repo_id(). ReturnsNonewhen sharing isdisabled, the user is anonymous, or the template is missing.
_spawn_uploader()helper to keep subprocess args in one place.save_and_upload_detachednow spawns two detached subprocesses: onefor the org dataset (row format, existing token chain) and one for
the per-user private dataset (Claude Code format,
HF_TOKEN).retry_failed_uploads_detachednow acceptspersonal_repo_idandruns both retry passes in parallel.
agent/core/agent_loop.py: passpersonal_repo_id=session._personal_trace_repo_id()into the startupretry so personal uploads that failed in a prior session get
re-attempted on next launch.
CLI
agent/main.py: new/share-tracesslash command./share-tracesshows the dataset URL and current visibility./share-traces publicflips to public viaHfApi.update_repo_settings./share-traces privateflips back to private.create_reposo the first flip works even before anysession has been saved.
HF_TOKEN.agent/utils/terminal_display.py: added the command to the help text.Docs
README.md: new "Sharing Traces" section covering default behavior,the slash command, the opt-out flag, and how to override the template.
Edge cases handled
HF_TOKENmissing: personal upload is skipped, org upload is unaffected.retry path skips files that have never been tagged, so we do not
suddenly re-upload old sessions to a newly created personal repo.
upload paths run on every save, the Hub deduplicates by content hash so
the cost is small.