feat: add /upload-trace command to upload session trace to Hugging Face#2648
Merged
Conversation
Adds a runner-handled /upload-trace slash command (admin-gated, like /clear)
that uploads the current session's Claude Code transcript to the user's own
private {hf_user}/nanoclaw-traces dataset, browsable in the HF Agent Trace
Viewer. The transcript is already in the format the viewer auto-detects, so
the command just locates the newest one and pushes it via the Hub commit API.
Auth is handled by the OneCLI gateway: curl goes out through the injected
HTTPS_PROXY, which adds the user's HF token — no credential ever touches
agent code. A missing/unassigned token yields a clear setup message.
- container/agent-runner/src/upload-trace.ts: isUploadTraceCommand() + uploadTrace()
- poll-loop.ts: recognize and handle /upload-trace in the runner
- command-gate.ts: admin-gate /upload-trace on the host
- upload-trace.test.ts: unit + integration coverage for the command
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
75eae0f to
729cd8d
Compare
Collaborator
Author
This was referenced May 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Type of Change
.claude/skills/<name>/, no source changes)Description
What — A runner-handled
/upload-traceslash command (admin-gated, like/clear) that uploads the current session's Claude Code transcript to the user's own private{hf_user}/nanoclaw-tracesdataset, viewable in the HF Agent Trace Viewer. Private by default.Why — Lets users browse, share, and debug their own runs in the HF trace viewer. The agent-runner already emits Claude Code JSONL natively, so it's a near-free addition — no format conversion needed.
How it works — The runner intercepts
/upload-tracein the poll loop (same path as/clear), so there's no LLM turn and no token cost.uploadTrace()locates the newest~/.claude/projects/*/*.jsonl, idempotently creates the private dataset, and pushes the file via the Hub commit API. Auth rides the OneCLI gateway:curlgoes out through the injectedHTTPS_PROXY, which adds the user's HF token — no credential ever touches agent code. A missing/unassigned token returns clear setup instructions instead of failing silently. The command is admin-gated host-side incommand-gate.ts.How it was tested —
bun test(container): a dedicatedupload-trace.test.tswith unit coverage forisUploadTraceCommandand an integration test of the runner-handled path. All pass; container + host typecheck clean. Verified live end-to-end:/upload-tracefrom Telegram uploaded the session to a private HF dataset and returned the trace's blob link.Usage — Send
/upload-tracefrom an owner/admin chat. On success it repliesUploaded → https://huggingface.co/datasets/<user>/nanoclaw-traces/blob/main/sessions/<id>.jsonl.🤖 Generated with Claude Code