Skip to content

feat(dashboard): expose tool context and rendered tokens - #3377

Merged
mikasenghaas merged 12 commits into
mainfrom
feat/dashboard-rendered-trace-view
Aug 25, 2026
Merged

feat(dashboard): expose tool context and rendered tokens#3377
mikasenghaas merged 12 commits into
mainfrom
feat/dashboard-rendered-trace-view

Conversation

@rasdani

@rasdani rasdani commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Summary

  • show trace.tools as a distinct, collapsible model-context block in the Messages view, with tool counts/names, full descriptions, formatted parameter schemas, and per-item/schema/all copy actions
  • add a separate Rendered view that decodes recorded post-renderer token_ids for the selected trace and branch as a full sequence, retaining special tokens and offering decoded-text and authoritative-ID copy actions
  • compose both Messages and Rendered with the Text, Advantage, Logprob, Mask, and Content signal dropdown, with explicit unavailable states for missing IDs, missing model metadata, tokenizer load failures, and decode failures

Details

The Messages view continues to render literal message.content. Tool definitions are shown immediately after the first system message in a purple-accented context card, so they are not presented as system-message text; traces without a system message keep the card at the top. The collapsed row shows the count and normalized names; expanding it exposes each full description and scrollable JSON schema. Direct tool objects, OpenAI-style function wrappers, multiple definitions, missing fields, and malformed values degrade to readable fallback labels.

Rendered does not rerun or infer a chat template. The server uses client.renderer_model_name with the existing run-model fallback, concatenates the recorded node spans in the selected root-to-leaf order, and calls the tokenizer once for the full sequence with special-token skipping disabled. The selected branch controls which decoded sequence is shown; the all-branches option uses recorded node write order. With Text selected, Rendered shows that exact full-sequence decode. With another signal selected, it shows the same recorded sequence as token spans with the existing color scale and token hover metadata.

Compatibility is intentionally additive: the default endpoint response and default Messages/Text display stay unchanged, token strings are still fetched lazily for overlays, and full rendered text is only added when rendered=true is requested. The mode buttons and signal dropdown are independent, and a one-time preference migration recovers sessions that briefly saved Rendered in the signal field.

Episode navigation and token/render enrichment use separate request lifecycles. Opening or closing an episode invalidates prior enrichment, while changing controls during an in-flight open no longer discards the episode response; the newly opened episode then picks up any enrichment required by the latest controls. Decode failures remain branch-local in the viewer: valid text for the selected branch is shown even if another branch fails to decode.

Verification

  • uv run --no-sync ruff format --check src/prime_rl/dashboard/server.py
  • uv run --no-sync ruff check src/prime_rl/dashboard/server.py
  • uv run ruff check src/prime_rl/dashboard
  • node --check src/prime_rl/dashboard/static/app.js
  • git diff origin/main...HEAD --check
  • exercised a generic synthetic two-branch trace through the live dashboard API with three tool-definition shapes; verified renderer-model selection, retained <|im_start|> / <|im_end|> markers, separate branch text, all-node ordering, and existing per-token pieces

Visual description

A compact Tool definitions · 3 tools · lookup, calculate, tool 3 row appears directly after the system message. It expands into nested tool cards with full prose and scrollable monospace schemas. Messages / Rendered buttons sit beside a signal dropdown containing Text, Advantage, Logprob, Mask, and Content. Either mode can use any signal; Rendered/Text shows the exact decoded transcript, while Rendered with an overlay shows colored token spans. A hover tooltip describes the signal choices. A screenshot is not included because a browser runtime was unavailable in the checkout used for verification.


Note

Low Risk
Additive dashboard and optional episode API fields; no changes to training, auth, or data persistence beyond larger lazy-loaded episode payloads.

Overview
The trace viewer adds Messages vs Rendered modes and surfaces trace.tools as model context separate from message text.

In Messages, tool definitions appear in a collapsible context block (after the first system message when present), with descriptions, parameter schemas, and copy actions; message bodies still show literal message.content. Rendered decodes recorded post-renderer token_ids per branch (or all nodes) via renderer_model_name with run-model fallback—no chat-template reconstruction—and reports missing IDs, model, tokenizer, or decode failures.

The episode API accepts optional tokens and rendered query params; rendered_token_text on the server concatenates branch paths and decodes full sequences with special tokens retained. The UI lazily fetches enrichment, versions open/enrichment requests to avoid stale responses, and shares the Text / Advantage / Logprob / Mask / Content signal dropdown across both modes.

Reviewed by Cursor Bugbot for commit 596f7d3. Bugbot is set up for automated code reviews on this repo. Configure here.

@rasdani
rasdani marked this pull request as ready for review August 25, 2026 02:52
Comment thread src/prime_rl/dashboard/static/app.js Outdated
Comment thread src/prime_rl/dashboard/static/app.js

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit f9df7ec. Configure here.

Comment thread src/prime_rl/dashboard/static/app.js Outdated
@rasdani
rasdani requested a review from mikasenghaas August 25, 2026 03:55
@rasdani

rasdani commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author
image image image

@mikasenghaas
mikasenghaas merged commit 3460245 into main Aug 25, 2026
19 checks passed
@mikasenghaas
mikasenghaas deleted the feat/dashboard-rendered-trace-view branch August 25, 2026 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants