Repository navigation
Render Dang tool calls as code in dagger agent - #15164
Merged
Merged
Conversation
vito
force-pushed
the
dang-tool-rendering
branch
6 times, most recently
from
November 13, 2026 22:43
ff25393 to
3cb4055
Compare
vito
force-pushed
the
dang-tool-rendering
branch
from
November 14, 2026 00:34
3cb4055 to
ce3ea47
Compare
grouville
self-requested a review
November 14, 2026 01:34
grouville
approved these changes
Nov 14, 2026
A tool call's span records its header arguments: the required ones, plus a few useful optional ones. Also record the Dang builtins' `at`, `search` and `source`, and a Timeout's `arguments` for the tool it wraps, as JSON, so frontends can show a Dang call's snippet and present a Timeout as the call it runs. Signed-off-by: Alex Suraci <[email protected]>
ToolCallView is how a tool call presents: a Timeout as the call it wraps, with its duration, and a Dang builtin as its snippet. A Timeout recognizes its nested call by span name, the tool as the model calls it, so snake_case tools of a server match too. It reads a call's arguments from the JSON its display span streams, which the DB now keeps for these tools, falling back to the span's recorded arguments. The streamed JSON matters for running calls: a live span's attributes only reach a client when it starts and ends, while its streamed arguments arrive as soon as the model wrote them. The DB drops streamed arguments it kept as soon as a span turns out not to render from them. Signed-off-by: Alex Suraci <[email protected]>
A DangEval or DangCheck call shows its snippet beneath its header in a small editor view: line numbers in a faint gutter, the code highlighted by Dang's own highlighter in the REPL's 16-color palette, lines wrapped to the terminal, and a collapsed call cut to its first 16 lines. The header names the scope (`at`) and a DangCheck's search. Without color, or for a source that won't highlight, the snippet renders plain. The highlighter compiles a WebAssembly module on first use, so it warms in the background: live views render the first snippets plain and redraw once it's ready, while final renders wait for it. A Timeout presents as the call it wraps, with that call's own rendering (a wrapped Read or Grep collapses and summarizes as the bare tool does), noted `timeout=2m`. Its header takes the server and bare tool name from the nested span once it runs, and expanding it shows the nested call without repeating the snippet. The final report shows a Dang call's snippet in full in place of its JSON arguments, shows a Timeout's call once, and rolls up what that call ran under the Timeout's row. Signed-off-by: Alex Suraci <[email protected]>
vito
force-pushed
the
dang-tool-rendering
branch
from
November 14, 2026 02:29
ce3ea47 to
93f1cff
Compare
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.
Makes the Dang builtins from #15156 look good in
dagger agent. ADangEvalorDangCheckcall now shows its snippet as code. ATimeoutcall shows up as the call it wraps.What it looks like
These samples were captured from a live
dagger agentsession against an engine built from this branch, with a real model. ANSI is stripped. In color, the code uses Dang's own highlighter and the REPL's 16-color palette. The gutter andtimeout=label are faint.DangEval. The line numbers match the
<check>:L:Cpositions in diagnostics.DangEval with
at. The scope is shown in the header, in cyan like a path.DangCheck. With
sourceit gets the same treatment. With onlyatand/orsearch, it's a one-line header.Timeout wrapping DangEval. It renders exactly like a DangEval, plus a
timeout=2mlabel. The label is styled like Read'soffset=20.Timeout wrapping other tools. A tool with a summary of its own keeps it. An unknown tool falls back to the generic header. A Timeout whose wrapped tool isn't known (an older engine) stays as it was.
Narrow terminal (44 columns). Lines wrap under a blank line number.
Long snippet. A collapsed call shows 16 lines. Expanding it, or the final report, shows all of them.
Prior art reused
Tool calls already get special rendering in two places:
renderer.renderSpan→renderToolArgsSummaryreadsdagui.SpanSnapshot.ToolArgsSummary(dagql/dagui/toolargs.go). That function works from theLLMToolArgNames/LLMToolArgValuesspan attributes thatcore/mcp.gorecords. This is how Read gets a cyan path andoffset=20.text/x-diffviaVterm.WriteDiff, which is how edits show a highlighted patch.This PR extends the header half and adds a sibling block under the row:
dagui.ToolCallView(dagql/dagui/toolcall.go) presents a tool call from its full arguments. It unwraps Timeout and exposes a Dang call's snippet.renderSpanasksrenderToolCallTitlefirst.renderInlineLogs, and the final report'srenderMessageLogs, put the snippet above the call's output. The snippet replaces the raw JSON args that verbosity ≥ 2 used to show for these calls.Where the arguments come from
at/search/source, and Timeout'sargumentsas JSON (core/mcp.go). These cover history replay, Cloud traces and reports.application/jsonlogs). A live span's attributes only reach the client at start and end, so without this a running DangEval would show no code until it finished. That's exactly when you want to see it, e.g. a long run under Timeout.dagui.DBkeeps that JSON only for these three tools, capped at 256 KiB per call.Timeout
A Timeout runs its call under a nested display span of its own, and that span normally hides under the Timeout's roll-up. Once that span exists, the Timeout's header takes the tool's server and bare name from it: the model calls it
editor_read, the header sayseditor Read.A wrapped Read or Grep collapses its output the way the bare tool does. In the final report, the nested call isn't printed a second time; whatever it ran (checks, tests, …) rolls up under the Timeout's row instead. When the Timeout is expanded, the nested row doesn't repeat the snippet.
Degrading
NO_COLOR, agent env, engine-side reports, which pin Ascii): plain text, nothing highlighted, the highlighter isn't even loaded.dang.Highlightreturns no spans and the code renders plain. It's also wrapped in arecover. A test checks that styled output, stripped of ANSI, always equals the plain output for broken, partial, multibyte and control-character sources, at several widths.~/.cache/dang/wazero). This happens in the background: the first snippets render plain and redraw once it's ready. Final renders wait for it.--progress=plain) doesn't render tool-call rows specially today, and still doesn't.Dependency
#15156 pins
github.com/vito/dang/v2at v2.5.0, which has everything this needs:dang.Highlight, and tree-sitter compiled to wasm and run by wazero (vito/dang#303, vito/dang#307, vito/dang#314), so there's no cgo.The CLI now links
pkg/dangfordang.Highlight. It still builds withCGO_ENABLED=0; I checked with a real build ingolang:1.26-alpineagainst v2.5.0.Testing
dagql/dagui/toolcall_test.go: unwrapping Timeout from attributes and from streamed JSON, falling back to attributes, the size cap, pruning args that arrive before their span,Wrapswith snake_case server tools, collapse.dagql/idtui/dang_render_test.go: transcript frames for each case above (Ascii, ANSI, 24 columns), long snippets, the final report, Timeout borrowing its nested call's label/collapse/rollups, rendering plain until the highlighter is warm.core/mcp_test.go: the recorded header args.golangci-lintpasses. I also QA'd live indagger agentwith a real model against an engine built from this branch.