AI observability

On this page

AI: agents, models and MCP servers

The AI page shows what the agents, models and MCP servers of bx-ai are doing on this server: how many runs, how they end, how long they take, what they cost, how every agent is composed, and how the MCP servers you host are doing. It sits in the Modules group, because it is an integration with the bx-ai module.

It is a BoxLang+ page. Without a license it shows three counters and nothing else (see Without BoxLang+).

Turn it on

The integration is off until an admin turns it on, under Modules, Integrations, on the AI page itself, or with collectors.aiobs.enabled in boxlang.json. With it off Lens registers no listener. It needs bx-ai, which ships with BxLens.

How the numbers are gathered

SourceWhat it gives
The events of bx-ai (every agent, no code change)Runs, model calls, tokens, tool calls, MCP calls, searches, speech, images, embeddings, rate limits and errors.
The Lens recorder (a passive middleware that Lens attaches to each agent as it is created, when collectors.aiobs.attach is on)The exact error and time of a tool that fails, and the attempts of a model call. bx-ai announces nothing when a tool throws, so without it a failed run is closed by a sweep a few seconds later.
What bx-ai keeps (agent.getConfig(), the registries, the statistics of an MCP server)How an agent is made, what is registered, and the numbers of the MCP servers you host.

The recorder never changes a run. Every hook catches its own errors and lets the run continue. Names and order of the middleware of an agent come from its configuration. bx-ai announces no events for middleware, so Lens reports what it sees at the edges of a run (retries, tool failures, failed runs), not what each middleware decided.

Lens keeps only values taken from these objects, never the objects, so nothing is kept alive by it.

Tabs

The AI overview: runs, success, run time, tokens, cost, what needs attention, and the agents, MCP servers and models | Tab | What it shows | |---|---| | Overview | The whole picture: runs, success, run time (p95 and median), tokens and cost. What needs attention. The top agents, the MCP servers you host and the top models. | | Agents | A dashboard of all agents (tiles, the slowest, the tools failing most, the middleware in use) and a mini report for each agent. Click an agent to open it. | | MCP | Every MCP server you host, in one table with its state, tools, resources, requests, tool calls, p95, failures, rejected callers, rate limited calls and health, and the top consumers of the rate limits. The servers your agents call. Click a server to open it. | | Activity | Every agent run and every direct call, with its trace: chat and model calls, tools, MCP calls, speech and transcription, images, embeddings and web searches. Filter by kind, status, slow or delegated, and search. A call made without an agent is listed too. Each priced run shows a cost estimate from its tokens and your price table, and a dash when the model has no price or the run has no tokens. | | Models and cost | Four views. Models: calls, p50, p95, tokens, rate limits, errors and cost for each provider and model, and which agents use it. Cost: spend by model and by agent, per day and per run, from your price table. Profiles: the named model setups of bx-ai 3.7 and newer, with provider, model, whether a key is set (never the key) and the agents that use each. Providers: where each provider's key comes from. | | Catalog | The tools, skills and gateways registered in bx-ai. Agents and MCP servers are not repeated here, they have their own pages. |

The AI settings button at the right of the tabs opens the AI observability area of Settings: the recorder, content capture, how many runs are kept, the limits for what needs attention, your price table, and a read only view of the bx-ai settings that matter for safety.

The range buttons (1h, 24h, 7d, 15d) and the server selector apply to the dashboards (Overview, Agents, MCP, and Models and cost). The pages about one run, the composition of an agent, the registries and the MCP servers hosted here describe this server only.

One agent

The agents dashboard

Open an agent from the dashboard. It has five sections:

  • Composition is a diagram of how the agent is made: its model, instructions, memory, skills, MCP servers, tools, sub-agents and middleware, each with how it performs. Click a part to go deeper.
  • Runs lists only the runs of this agent. Open one for its trace.
  • Tools and parts shows each tool with its calls, time, failures and share of the time of the agent, the sub-agents it delegates to, the MCP servers it calls, its models, skills and memory.
  • Middleware lists the stack in the order it runs, what Lens saw, and the flight recorder middleware of bx-ai when the agent has one: its mode, how many tapes it wrote and which run each belongs to. Lens lists the tapes and does not replay them. A tape holds raw prompts and answers, so only names, sizes and counts are read.
  • Instructions shows the size and a short hash of the instructions, the text when content capture is on, and the versions: a new hash starts a new version with its own runs, failures and p95, so you can see whether a prompt edit helped.

An agent and how it is composed

Agents with many parts

An agent can have dozens of tools and several sub-agents, so a card shows only the few that matter: the failing ones first, then the most called (5 of each). The last chip says how many more there are (+35 more), and pressing the card opens its tab (Tools and parts, Middleware) with the whole list. A long table there has a filter box and a count, and its rows scroll under a header that stays. The same filter is on the tools of an MCP server and on the Registries. Every card of the diagram, every tab of the page and every list of the Registries has an icon. Press a sub-agent chip to zoom into that sub-agent: it opens with the same diagram, and the trail above it (All agents / ops-assistant / billing-agent) takes you back one step at a time.

An agent with 40 tools: the card shows the failing and the busiest tools and a chip with the rest

One MCP server

The MCP servers you host

Open a server you host. It shows its requests, tool calls, resource reads, failures and p95, what failed grouped by error, and what to check. A call for a tool the server does not have, for example, says what the server lists instead. A second tab lists the requests and why callers were turned away (auth, API key, IP list, size).

One MCP server: what failed and what to check

The numbers of a hosted server are read from the statistics bx-ai keeps for it, so they count requests made without HTTP too. The tool table counts since the server started.

Rate limits

A server with a rate limit (bx-ai 3.7 or later) has more on its page and on the MCP table:

  • A Rate limited tile and table column: calls the limit blocked in the range, with a trend. The Rejected tile still adds up every refusal, including these. A request the limit blocks never reaches the MCP events, so Lens reads the counters of the server and counts the change.
  • A Rate limit card: the limits (for example 60 per 60 s, 1000 per 3600 s, by ip), blocked in the range, let through since the server started, store errors, how long history is kept, and whether trusted proxies are set.
  • Top consumers with the buttons Today, 7 days, 30 days and All time: client, type, requests, blocked, the busiest minute and the share of the limit it reached. An IP shows plain, an API key or a custom key shows as a short hash, never the key. Today and the days come from the history bx-ai keeps in its cache (retentionDays), so they follow its retention and include every node that shares that cache. All time comes from running totals BxLens keeps for the 50 heaviest clients of each server, counted from the day it first saw them (a store is needed to keep them over a restart). With the server selector on all servers, all time merges the saved totals of every server.
  • Recent rate limit hits: a sample of who was blocked, newest first. bx-ai sends at most ten of these a minute, so this list is a sample and the counts above it are exact.
  • What to check gains hints: a client held at the limit, no trusted proxies set while the limit is by IP, a store that fails.

An admin on this server can act from the server page (BoxLang+, refused when console.readOnly, never for another server, each change in the audit log as ai.mcp.host):

ButtonWhat it does
Pause server, Resume serverpause() and resume(): a paused server answers only ping
Turn limit off, Turn limit ondisableRateLimit() and enableRateLimit(): the setup, counters and history are kept
Reset countersresetRateLimit(): every client has its requests back (needs a store that can clear, the cache and memory stores do)
Clear statsresetRateLimitStats(): clears the stats and the history of the server

The alerts have two rules, MCP rate limited and MCP rate limiter failing, that can be switched on and off alone, see the alert runbook. The reports have an MCP section.

The trace of a run

A run is a tree of steps: model calls, tool calls, sub-agents, MCP calls and searches, nested the way they ran, with the time and tokens of each. A sub-agent is a tool named delegate_to_<name> in bx-ai, so Lens links the run of the sub-agent to the run that delegated. A failed tool shows its error and time. A run whose tool threw never announces its end: Lens closes it as failed as soon as the thread does something else, or a few seconds later.

The trace of a run

What needs attention

RuleLimit (setting under collectors.aiobs)
An agent, a tool or a model fails on this share of its callsfailurePct (5), judged once it has minCalls (20) calls. Critical at twice the limit.
An agent is slow: its p95 is this many times its median, and at least 2 sslowFactor (3)
Rate limits from a provider in the last 10 minutesrateLimits (3)
MCP errors of one server in the last 10 minutesmcpErrors (4)
MCP calls one server blocked with its rate limit in the last 10 minutesmcpRateLimited (30)
A model has tokens and no pricealways, as a note
Runs that never finishedalways
A setting of bx-ai that opens a dooralways, see below

Settings of bx-ai that are worth a look

These are read from bx-ai and shown in the list. BxLens never changes them.

ItemWhen it shows
logRequest is onEvery prompt is written to the ai log, including what users typed.
An MCP server runs as a child process and mcp.stdio.allowedCommands is emptyAny command is allowed.
A hosted MCP server limits by address and mcp.server.trustedProxies is not setA client can send its own forwarded address.
A hosted MCP server has no rate limitA note.
An agent uses a profile whose provider has no API keyThe agent will fail on its first call.

Profiles in boxlang.json

BoxLang AI 3.7 reads its profiles from the profiles and defaultProfile settings. BoxLang AI is bundled inside the BxLens module, so a nested module takes its overrides from its parent: put them under the BxLens entry, in modules, bxai, settings.

{
  "modules": {
    "bxLens": {
      "modules": {
        "bxai": {
          "settings": {
            "defaultProfile": "fast",
            "profiles": {
              "fast": { "provider": "ollama", "model": "llama3.2" },
              "deep": { "provider": "ollama", "model": "llama3.2:70b", "params": { "temperature": 0.2 } }
            }
          }
        }
      }
    }
  }
}

A modules.bxai.settings block at the top level of boxlang.json does not reach the bundled module. The same path sets every other BoxLang AI setting, for example mcp.stdio.allowedCommands and mcp.server.trustedProxies. The Profiles view and the Settings area show what was loaded.

Run markers

A profile switch, a cancel and a steer appear in the trace of a run as marks (bx-ai 3.7 and newer): onAIProfileSwitch, onAIAgentRunCancel and onAIAgentRunSteer. The called MCP servers show their transport, http or stdio.

Cost

Cost comes from a price table you enter in Settings, under AI observability: dollars per million tokens, for the input and the output of each model. Nothing is guessed. A model with no price adds no money, and the Cost tab says how many models have none. Every amount is labelled an estimate, because tokens are counted as the provider reports them and prices change.

The AI observability area of Settings: the bx-ai setup and the price table

Prompts and answers

Nothing of the text is kept by default. An admin can set collectors.aiobs.content to preview (the first 200 characters) or full (up to 20,000). Whatever is kept is redacted first: secrets, emails and numbers that look like cards are hidden. Only an admin sees the text, whatever the setting. A viewer sees the numbers.

Without BoxLang+

The AI page on Free

Free keeps four counters for the last hour: failed runs, rate limit hits, MCP errors and MCP calls blocked by a rate limit, and shows a locked preview of the rest. No run list, no names and no text. They are counted while the integration is on. The recorder is not attached on Free.

What is stored

Memory keeps the last hour on Free and two days with the store. With BoxLang+ the numbers are saved as a rollup of each UTC day (ai-rollup-YYYY-MM-DD.json), so other servers can be read and a restart does not start from zero, finished runs are saved to the stream ai-runs, and the heaviest rate limit clients of each server are saved as the snapshot ai-consumers (50 clients per server, an IP or a short hash, never a key). See The store. The list of runs in memory is bounded by collectors.aiobs.maxRuns (500). Retention is the one of the store (store.retentionDays).

Limits

What the page cannot show today, and why.

  • No counters for each middleware. bx-ai announces no events for middleware, so Lens cannot say how many requests a guardrail blocked or how often a retry middleware fired. The Middleware tab lists the stack in order, with its names and descriptions. What Lens does show is what it sees at the edges of a run: retries, tool failures and failed runs.
  • The flight recorder is listed, not replayed. For an agent with the flight recorder middleware of bx-ai, Lens shows its mode and its tapes: names, sizes and the number of steps. It never opens the content of a tape, because a tape holds raw prompts and answers, and it does not replay one.
  • Tokens are never estimated. Providers that report no token numbers show none, and a model with no price adds no money.
  • bx-ai announces no event when an agent run, a tool or a model call throws. The recorder gives the tool error, and a sweep closes the run.
  • An agent made with new AiAgent() instead of aiAgent() announces no creation event, so Lens does not attach the recorder. Its runs are still counted from the other events.
  • A tool run by an MCP server hosted here is counted by that server's statistics, not as a tool of an agent.
Edit this page Download Markdown Last updated Nov 26, 2026, 8:34:30 AM Report an issue