feat: show sub-agent run-stats (tools · tokens · time) on completion#16
Merged
Conversation
Spec for rendering a Claude-Code-style completion summary (tools · cumulative tokens · elapsed) when a spawned sub-agent finishes, in both the TUI and the plain CLI. Cumulative token tracking requires a small cogito-side accumulator exposed on the returned fragment. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Temporary: lets nib build against the un-released CumulativeUsage change. Removed once cogito is tagged (see plan Task 9).
…al replace cogito's CumulativeUsage (mudler/cogito#55) is now released on main, so nib depends on the published pseudo-version and the dev-time local replace is removed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
56b1ad9 to
b6b4aa8
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.
Summary
When a spawned sub-agent finishes, nib now shows a one-line run summary in both the TUI and the plain CLI:
chat.AgentEventcarries three new completion fields:ToolCount,TotalTokens,Elapsed.emitAgentEventtimes each sub-agent (spawn → completion via a mutex-guarded start-time map) and readslen(Fragment.Status.ToolsCalled)+Fragment.Status.CumulativeUsage.TotalTokensfrom the completedAgentState.Fragment(nil-safe for failed agents).humanTokens,humanDuration,AgentEvent.StatsSuffix) render the suffix, omitting zero/unknown segments.completedline.Cumulative tokens are the sum across every LLM call the sub-agent made.
Depends on
Status.CumulativeUsage). Before merge: drop the localreplace github.com/mudler/cogito => …ingo.modand bump to the released cogito version once #55 is tagged.Test Plan
chat/agentstats_test.go:humanTokens/humanDurationboundaries;StatsSuffixplural/singular + zero-omission.chat/agentusage_test.go:agentUsagenil-fragment and populated cases.tui/agents_stats_test.go: completed transcript line contains the stats segments.cmd/cli_agents_test.go: CLI completed line contains the stats segments.go test ./...+go vet ./...green; manual end-to-end review of the cogito→AgentState→event→render chain.🤖 Generated with Claude Code