Skip to content

Repository files navigation

Agent Lens

A free observability lens for Kestra AI agent runs. Paste an execution's outputs JSON, get the run rendered the way an operator should read it: tool-call timeline, token usage with an estimated cost, the thinking chain, and the RAG sources the answer leaned on.

🔗 Live: agent-lens-kestra.vercel.app · Built by Roman Martins · Independent and unofficial — not affiliated with Kestra.

Why

Kestra's AI tasks (io.kestra.plugin.ai.*) record everything an agent does — tokenUsage, toolExecutions, intermediateResponses, thinking, sources, guardrail state — but the UI shows it as raw JSON in the Outputs tab. Kestra's own backlog describes the missing experience (kestra#15497: prompt/response viewer, tool-call timeline, cost estimates). Agent Lens is a zero-install way to read that data today.

Companion to Flow Doctor: Flow Doctor checks the flow before deploy (lint), Agent Lens inspects the run after execution (observability).

What it shows

Section Source fields
Stat cards (tokens, tool calls, LLM time, finish) tokenUsage, toolExecutions, requestDuration, finishReason
Cost panel (editable prices, monthly projection) tokenUsage × bundled list-price table (model picked by user — the run doesn't record it)
Tool-call timeline intermediateResponses[].toolExecutionRequests matched to toolExecutions by request id
Thinking thinking (when returnThinking was enabled)
RAG sources sources[] with open metadata
Guardrail banner guardrailViolated / guardrailViolationMessage (minimal-shape outputs handled)

Accepts a bare task-outputs object, a full execution JSON (scans taskRunList[].outputs, multi-task switcher), or an outputs map keyed by task id.

Schema fidelity

Field names verified against the plugin source (kestra-io/plugin-ai, main): AIOutput.java, TokenUsage.java, plus the completion/rag.ChatCompletion output variants. Honours Kestra's NON_NULL serialization (absent ≠ null) and the flattened requestId/requestName/requestArguments tool-execution shape. Full notes: /methodology.

Architecture

  • 100% client-side. The JSON never leaves the browser — no backend, no account, no upload.
  • Next.js 14 (App Router) + Tailwind. Parsing/analysis is plain TypeScript in lib/.
lib/types.ts      # AIOutput mirror types + derived analysis shapes
lib/parse.ts      # input detection, timeline reconstruction, warnings
lib/pricing.ts    # model list-price table (editable in UI), matching, math
lib/fixtures.ts   # example payloads (healthy / expensive-truncated / guardrail)
lib/__tests__/    # vitest suite (19 tests)
components/       # Header, Footer, RunInspector (client), Report
app/              # home, /methodology, /about

Develop

npm install
npm run dev      # http://localhost:3010
npm test         # vitest — parser + pricing
npm run build

Caveats

Reads what Kestra recorded — no provider usage report means no cost estimate. Prices are public list prices (as-of date shown in the UI), excluding cached-input/batch discounts. Schema drift in future plugin versions can break parsing.

About

Agent Lens — observability for Kestra AI agent runs. Paste an execution's outputs JSON: tool-call timeline, token cost, thinking, RAG sources. Independent & unofficial.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages