Link the demo's trace to exact lines of code

#2
by lewtun HF Staff - opened
Hugging Face Agent Swarms Research org

What

Exact-line links in the demo's trace, instead of whole files:

  • Reply text: "the reply's text is in knowledge/science.py, line 2,911" links to that line (the gravity answer; the same line the video shows).
  • Winning module: its name links to its own respond() in bot/modules/<name>.py (e.g. answers.py#L8331-L8577).
  • File map: clicking a highlighted file opens the reply's line, the winner's respond(), or the first function the winner ran in that file. The hover text says which.

Why

Lewis asked whether the demo could point at the code that ran, not just the file (option 1 of the three discussed on the board).

How

  • pybot_web.py: the existing sys.monitoring trace now also records each function's line range. It unwraps the bot's decorators to find each handler's own respond(): 97 of 97 found. The reply-text match becomes a line number.
  • build/build_bundle.py: the bundle gains lines.json (letters/digits per line), +0.6 MB (22.2 MB). It's renamed pybot-24cbc0439e07-c4076a39.zip so browsers fetch it instead of a cached copy. Same bot: bot/ at 24cbc04, from huggingface/pybot.
  • tree.json: ref is the commit 7d63c7f instead of main, so line links don't drift when main changes.
  • index.html: only the explanation line's two names become underlined links, plus the hover text. Layout, fonts and colours are unchanged.

Testing

  • 40 recorded conversations from the leaderboard's 24cbc04 run replay byte-identically in the new bundle.
  • In headless Chromium: the gravity, joke and tea replies link to the lines holding their text (checked against the source at 7d63c7f), with no page errors.
  • tree.json matches the GitHub files at 7d63c7f (528 files, same line counts).

๐Ÿค– Generated with Claude Code

lewtun changed pull request status to open
lewtun changed pull request status to merged

Sign up or log in to comment