Skip to content

AI section

The AI group in the devtools sidebar has six pages. Three of them read hourly totals that are saved, so they keep their numbers across restarts and, in production, add up every process. The other three read the runs held in memory and exist in development only.

PageReadsDevelopmentProduction (default)
ReportsHourly totalsYesOn when Panoptic is installed
RunsPanoptic traces in memoryYesNever (development only)
Agents@warlock.js/ai agent traces in memoryYesNever (development only)
ModelsHourly totalsYesOn when Panoptic is installed
ErrorsHourly totals (and recent failed runs)YesOn when Panoptic is installed
EvaluateGrades a system prompt with a judgeYesOff

Runs, Agents and Evaluate show prompts, tool data and run details, so they stay in development. production.panels.ai and production.panels.agents are ignored in production, with one warning at boot. See Devtools in production for the production setup.

Install devtools as usual, then add Panoptic if your app does not already use it:

Terminal window
warlock add devtools
npm install @warlock.js/ai @warlock.js/ai-panoptic

Configure observation at application boot:

import { ai } from "@warlock.js/ai";
import "@warlock.js/ai-panoptic";
ai.config({ panoptic: { observeAll: true } });

Restart warlock dev, make a request that executes an AI flow, and open http://localhost:<port>/__warlock. No additional dashboard server or dashboard: true option is needed. Inside a Warlock app Panoptic’s own standalone dashboard does not start; it logs one notice that points at this section (see the local dashboard).

Installing Panoptic alone does not enable observation. Use observeAll: true, observe: true on individual flows, or the explicit subscriber APIs (panoptic().attach(...), panoptic().middleware(), flow-local observers and collector.collect(...) all feed these pages when they use Panoptic’s built-in collector; a custom collector must delegate to that pipeline). If Panoptic cannot be loaded, the pages show install or restart guidance and the other panels keep working.

When a page has nothing to show it says which case applies: @warlock.js/ai is not installed (warlock add ai), Panoptic is not installed (warlock add ai-panoptic), Panoptic failed to load (the load error, with file paths replaced, and both versions), observation is off (add ai.config({ panoptic: { observeAll: true } }) to src/config/ai.ts; old totals still show under a banner), the totals table is missing (run warlock migrate), or reports are turned off (devtools.ai.reports).

Filters shared by Reports, Models and Errors

Section titled “Filters shared by Reports, Models and Errors”

Every report page has one filter row: a range (24h, 7d, 30d or Custom), then Agent, Model and Provider. Filters scope every tile, chart and table on the page. The filters live in the address (#ai-reports/range=7d&agent=checkout), so a view can be bookmarked, and the last range is remembered so moving between Reports, Models and Errors keeps it. Pages refresh every minute.

  • 24h shows 24 hourly columns, 7d shows 28 six-hour columns, 30d shows 30 daily columns ending at your next local midnight. A custom range uses hourly columns up to 48 hours, six-hour columns up to 8 days, and daily columns beyond; daily columns always run from your local midnight to the next, so a custom range in days is widened to whole days.
  • Every figure is compared with the period of the same length right before it (for example “up 12% vs previous 7 days”). A rising error rate or p95 uses the warning tone; the others stay neutral. When part of that earlier period is older than the kept history (the 30-day range with the 30-day development default, for example), the change reads No earlier data instead of a misleading figure.
  • A custom range cannot start before the retention cut-off (see Retention).

Tiles: Estimated cost, Tokens (input, output and cached), Agent runs, Error rate and p95 latency, each with its change against the previous period. Charts: Estimated cost by model (top five models plus Other), Tokens (uncached input, cached input, output) and Error rate (a gap where an hour had no runs). Two tables list the top agents and the top models by estimated cost: runs, tokens, cost with a share bar, error rate and p95. Clicking a model opens Models for it; clicking an agent opens Agents. Every chart has a Table toggle that shows the same numbers as a table.

Cost is always labelled Estimated from model pricing. It is the usage.cost the model reported, from the pricing you set on the model, the SDK registry or the adapter’s list prices. A run whose model has no pricing is unpriced: its tokens are counted but it adds nothing to the cost, and the page shows the number of unpriced runs next to every cost. A model priced as free (pricing set to 0, for example a local model) counts as priced at $0, not as unpriced. When models have no pricing, a banner names how many (“3 models have no pricing; their runs are not in the cost”). Set pricing on the model to include them.

A run is one model-bearing step of a trace: an agent, or an image, speech or transcription call. An agent used as a tool inside another agent counts once, as itself, and its usage and cost are taken out of the caller’s own totals so nothing is added twice. Tokens are normalised so “input” is the whole prompt on every provider. Failed and incomplete runs count as errors; cancelled runs do not. Errors are grouped by their error type into Rate limit, Timeout, Refusal, Provider error (authentication, invalid request, context too long), Budget, Tool failed, Invalid output (schema validation), Incomplete (incomplete runs and runs that hit their trip limit) and Other.

The development page for single runs, as before, with filters and grouping added. Filter by text (run name or session), status, type and exact HTTP request id, and group by Session, Prompt or Type. Tiles show the runs, failed runs, estimated cost (with the number of unpriced runs when there are any), p50 and p95 of the filtered set. Opening a run shows the span tree with a cost tint on each span (stronger for the costlier spans; the number is always shown). #ai/<traceId> links keep working, and a run’s Open HTTP request button returns to its request record while that record is retained.

Agent, image, speech and transcription runs all appear here with the model they used (for example mock/mock-image), and the same model shows in Models and Reports.

Runs are the Panoptic traces collected after devtools attached, bounded by maxRequests (200 by default) and independent of request retention. Clear, shutdown and restart discard them. Use the hourly totals for anything that must outlive them.

Unchanged: the per-turn traces @warlock.js/ai records for its own agents (system prompt, tools offered, tool calls, retries, usage and cost, and a comparison with the previous run). Above the list, Agents in the last 24 hours shows the top agents from the Reports data when that is available. It does not need Panoptic. See agent traces.

Tiles: models used, estimated cost, models without pricing and the fallback rate (runs where an earlier model of a fallbackModel() chain failed first). A chart shows Runs by model. The table has one row per provider and model: runs, tokens in and out, estimated cost, cost per priced run, a pricing pill (Pricing set, No pricing, Partly priced, or No tokens used when every run failed before using tokens), fallback rate, error rate, p50 and p95, and the agents that use it.

Tiles: failed runs, error rate with its change, refusals (runs where the model declined) and cancelled runs. A chart shows Failed runs by category over time. The table groups failures by category with the count, a share bar, the change against the previous period, and the top models and agents. In development, Recent failed runs lists the latest 50 failed runs inside the chosen range and filters (agents, and image, speech and transcription calls) with their message (cut to 300 characters) and a link to the run. In production run details are not kept, and the page says so.

Grades a system prompt with a judge model, from a page instead of code. It is development only because it spends a model call. When no judge is configured the page shows the setup:

src/config/ai.ts
import { ai } from "@warlock.js/ai";
import { openai } from "@warlock.js/ai-openai";
import "@warlock.js/ai-panoptic";
ai.config({
panoptic: {
observeAll: true,
evaluate: {
model: openai.model({ name: "gpt-4o-mini" }),
instructions: "The prompt must say which tone to use and what the agent must never do.",
},
},
});

With it, the page lists recent system prompts (the agents using them, when last seen, a preview and the length) and lets you paste one. Pick a prompt, adjust the instructions (they default to the configured ones; left empty, the configured ones are used, or the built-in rubric when none are set) and press Run evaluation. The result card shows a score as a percentage, the issues found, the judge and the time. Errors appear in the card next to the button. The prompt is capped at 100,000 characters and the instructions at 4,000. panoptic.evaluate takes the same settings as the standalone dashboard’s dashboard.evaluate; see Configuring Panoptic.

Reports, Models and Errors read hourly rollups. Each row holds names and numbers only (agent, model, provider, runs, tokens, estimated cost, errors by category, a latency histogram, fallback and refusal counts); no prompts, completions, tool data or user ids.

  • Development keeps them in files under storage/devtools/ai-rollups.
  • Production keeps them in the devtools_ai_rollups table of your app database, created by devtoolsMigrations. Every process that boots the devtools connector adds to the same table, so the pages add up all instances and workers, including queue workers that run the app. Run warlock migrate after upgrading.
  • Totals are saved every minute (a run shows on the page at once in the process that served it; other processes’ runs appear within the interval). On a clean shutdown the last totals are written.
  • Latency percentiles come from a histogram, so they answer the upper bound of a bucket rather than an exact value.
src/config/devtools.ts
export default {
ai: {
reports: true, // keep hourly totals (default true)
retentionDays: 30, // 1 to 400; default 30 in development, 90 in production
flushIntervalMs: 60_000, // at least 5000; default 60000
},
};
OptionDefaultMeaning
reportstrueKeep hourly totals. false turns the writer off; the pages say so.
retentionDays30 development, 90 productionHours older than this are removed every 10 minutes by every process.
flushIntervalMs60000How often unsaved totals are written (5000 or more).

An invalid value stops the boot and names the option. Raw run traces keep their own retention (the in-memory limit above).

FieldMeaning
ModelThe provider/model identity recorded on each agent span; multiple nested agents can contribute models to one run.
TokensRoot input/output usage plus provider cache-read and cache-write tokens. Missing optional counters appear as —. The input label says whether it includes cache tokens, using usage.inputIncludesCache.
CostHistorical USD amounts from usage.cost, summed with Panoptic’s totalCostUsd, including cache, reasoning and hosted-tool fees. Missing pricing is unpriced. Totals include reported costs only; a partly priced run can have a partial total.
Cache hitsNumber of trips with reported cachedTokens > 0. This measures provider prompt-cache hits. Semantic-cache hits are unreported because the current report contract carries no explicit hit flag; zero tokens alone do not prove a hit.
Tool callsNested tool spans with start/end timestamps, offset from run start, duration and status. Truncated tool requests that were never dispatched are not counted as executed tools.
RetriesRetry counts and each recorded attempt’s timestamps, duration and outcome.
Truncationreport.status: "incomplete" or an AgentIncompleteError (AGENT_INCOMPLETE) marks the run incomplete. Truncated-trip counts remain visible even if a later continuation recovered the run.
CompactionApplied/skipped agent decisions, trip index, input-token count, counting method, skip reason and replaced range. Provider compaction blocks contribute a separate count. Summary text and raw provider blocks are excluded.

Select a run to inspect its nested spans and diagnostic attributes. Root usage already includes children: totals do not add the same child usage again. Each span still displays its own recorded usage. A — cache count means unreported, which is different from a reported zero.

Orchestrator compaction returned only on a result envelope or emitted only as an event is outside the report tree and cannot be reconstructed from its trace. The panel displays the compaction metadata actually present in agent reports and provider blocks.

Devtools reads core’s request-local id synchronously when Panoptic collects the finalized report, before exporters run. Concurrent requests retain their own ids. Work completing after the response can still link if it retains that async context. If no current request id exists, an explicit Trace.requestId is used when present; otherwise the run appears as Background / no request id. sessionId is a separate conversation identity and is never guessed to be an HTTP request id. Reports collected later outside their original context cannot be linked retroactively.

The Runs page accepts an exact HTTP request id filter (requestId). Request details use that same filter, so late AI runs remain discoverable while their trace is retained. Updates arrive through the dashboard’s existing event stream when collection finishes; this is a completed-run view, not token streaming.

Devtools uses Panoptic’s in-memory query store, bounded by maxRequests (200 by default) AI traces, independently of request retention. Recollecting a trace replaces the same trace id. It captures runs collected after devtools attaches; it does not replay boot-time runs or hydrate an application’s persisted cache store. Clear, connector shutdown and process restart discard this view. Clearing it does not erase your application’s Panoptic exporter/cache stores. Use Panoptic trace stores for persistent history.

All paths are relative to the configured devtools prefix, answer with Cache-Control: no-store, and use the same guard as the rest of the dashboard (loopback in development; session, role and CSRF in production).

RouteAnswerNotes
GET /api/ai/reportsTotals, charts data, top agents/modelsrange, from, to, tz, agent, model, provider. Production: viewer.
GET /api/ai/modelsOne row per provider and modelSame query. Production: viewer.
GET /api/ai/errorsGroups by category, over time, recentSame query. recent is null in production.
GET /api/ai/runsFiltered, grouped runsq, status, type, session, requestId, prompt, groupBy, limit. Development.
GET /api/ai/evaluateWhether a judge is set, recent promptsDevelopment.
POST /api/ai/evaluateScore, issues, judge, timeBody { runId } or { systemPrompt }, plus instructions?. Development only.
GET /api/ai{ available, runs, aggregate }Unchanged. ?requestId=<id> scopes it to one HTTP request.
GET /api/ai/runs/<trace-id>The content-free trace tree, or 404Unchanged.
GET /api/ai/agent-runs[?requestId=<id>]Recent agent runsUnchanged. available: false with guidance until a trace store exists.
GET /api/ai/agent-runs/<run-id>The full agent trace, or 404Unchanged.

range is 24h, 7d, 30d or custom (default 24h); tz is minutes east of UTC. A bad query answers ai.range-invalid (400); a bad Runs query or evaluate body answers input.invalid (422). Evaluate failures carry ai.evaluate-unavailable, ai.prompt-not-found or ai.evaluate-failed, each with a message saying what to do. GET /api/stream adds ai events carrying { traceId, requestId? } and agent-trace events carrying { runId, status, requestId? }; DELETE /api/requests clears the in-memory views. DevtoolsAiRun and DevtoolsAiEvent are exported as types from @warlock.js/devtools.

The run views omit span input and output, prompts, tool arguments and results and compaction summaries, even if Panoptic’s other exporters capture content. warlock ai trace reads the agent endpoints from the terminal.