gateway: agent-scoped "Recent runs" table with user, model and time - #1691
Merged
Merged
Conversation
… user/model/time The AgentDetail page built its Recent runs table from /histogram/cost?dimension=run-id, which is not agent-scoped and orders by spend: selecting canvas-agent listed every agent's runs, ranked by cost, with the run just fired nowhere near the top. New GET /_plugin/agents/:name/runs (agentruns.go): one row per run in the window, filtered by metadata.agent-name, sorted by last activity (newest first), with user_id, models (most-used first), spend, tokens, call count and first/last seen. ?limit=/?offset= paging plus `total` for the footer. Timestamps compare as times, not strings, so sub-second RFC3339Nano trimming can't misorder rows. UI: useAgentRuns hook; the table shows Run (ellipsized, full id on hover), User (first 8 chars, links to /people/:id), Model (+N pill when a run used more than one), Spend, Calls, Last call (relative, absolute on hover). The cost chart now passes agent_name so the server filters instead of the page; the stale "phase-8 limitation" comment goes with it.
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.
Problem
On
/agents/:namethe Recent runs table was derived from/histogram/cost?dimension=run-id, which has no agent filter and sorts series by spend. So selectingcanvas-agentshowed every agent's runs (repo-agent, logs-agent, …), ranked by cost, and the run you had just triggered was nowhere near the top.Fix
Backend — new
GET /_plugin/agents/:name/runs?window=&limit=&offset=(agentruns.go), dispatched from the existing/_plugin/agents/subtree next to<name>/spend:run-id, scoped bymetadata.agent-name, newestlast_seenfirst (ties by run id for stable polling)user_id,models(most-used first),total_cost,total_tokens,request_count,first_seen,last_seentotal= run count before paging, so the UI can say "showing 50 of 120"…:00Zvs…:00.5Zlexicographically)UI —
useAgentRunshook (30s poll, the by-agent cadence). The table now shows:/people/:id, full id on hover+Npill listing the rest on hoverAlso: the cost chart now passes
agent_name=so the server filters it (the hook already supported this), replacing the client-side series filter and the stale "phase-8 limitation" comment.Tests
agentruns_test.go: scoping (another agent's run must not leak), newest-first order, models by call count, user from the first stamped row, orphan rows without run-id skipped, sub-second ordering, paging, 400/404/502.go test ./internal/adminapi/green;make tygoregeneratedtypes.ts;tsc -b --noEmitandvite buildclean.