ax-llm/ax/ax-agent-observability
Claude Code and agent skill by ax-llm/ax
- community
Checking that the SKILL.md file is still in the repository.
This skill helps an LLM generate correct AxAgent observability code using @ax-llm/ax. Use when the user asks about axGlobals.onUsage, usageContext, centralized or multi-tenant usage accounting, actorTurnCallback, onContextEvent, agentStatusCallback, onFunctionCall, reportSuccess, reportFailure, getChatLog(), getUsage(), resetUsage(), debug traces, progress updates, or telemetry for AxAgent runs.
Install
npx vskill@latest install ax-llm/ax/ax-agent-observabilitySKILL.md
The same SKILL.md was published earlier as ax-llm/ax/ax-agent-observability.
AxAgent Observability Rules (@ax-llm/ax)
Use this skill when an agent needs runtime visibility, progress reporting, tracing, usage accounting, or chat-log access. For ordinary agent setup use ax-agent. For RLM runtime policy use ax-agent-rlm. For memories and dynamic skill loading use ax-agent-memory-skills.
Choose The Smallest Hook
- Need a quick prompt/runtime trace during development -> start with
debug: true. - Need structured per-turn code, raw runtime result, formatted output, provider thoughts, or actor stage -> use
actorTurnCallback. - Need context-pressure and compaction telemetry -> use
onContextEvent. - Need real-time task progress emitted by actor code -> use
agentStatusCallback. - Need every runtime function call before execution -> use
onFunctionCall. - Need model prompts/responses after a run -> use
getChatLog(). - Need centralized chat/embed usage across APIs, users, agents, and services -> use
axGlobals.onUsageplususageContext. - Need token usage by actor/responder -> use
getUsage()andresetUsage(). - Need usage split by context and task stages -> use
getStagedUsage(). - Need Ax program traces -> use
getTraces(). - Do not add multiple hooks unless the user clearly needs each output stream.
Global Runtime Defaults
OpenTelemetry and debug defaults come from the shared Ax runtime surface:
Each agent run snapshots these globals. A forward-scoped rateLimiter, tracer, or meter overrides agent defaults, child-generator defaults, service hooks, and globals for that invocation. Ax carries it through the distiller, executor, responder, repeated actor turns, citation repair, built-in llmQuery, context-map work, checkpoint/tombstone summaries, and other direct internal model calls without mutating child programs or leaking across concurrent runs.
The limiter wraps model execution and its failures propagate. Tracer, meter, and usage-observer failures are fail-open. Runtime-hook spans contain metadata only—never prompts, outputs, tool arguments, or tool results—and preserve agent → internal AxGen → provider/tool parentage. External meter instruments do not replace or derive from balancer-local getMetrics() snapshots. Use AxAgent callbacks below when the caller needs structured agent-turn events rather than spans or metrics.
Centralized Usage Observer
Use the process-wide usage observer for application accounting across many agents, API routes, tenants, and users. Keep getUsage() for inspecting one agent instance after a run.
Rules:
- The observer receives one immutable normalized event for each completed chat or embedding call that reports provider usage. A fully consumed stream emits once; an unconsumed or cancelled stream may not emit.
- Events include
operation,ai,model, normalizedtokens,streaming, optionalcontext, and available session or remote request IDs. - Put stable attribution such as application or environment in AI service-level
usageContext. Put tenant, user, request, run, and feature attribution in per-call or per-forwardusageContext. - Per-call context overrides service defaults.
attributesare shallow-merged. - The observer is best-effort and fail-open. Ax does not await it and ignores observer failures, so synchronously enqueue and persist or aggregate out of band.
- The registration is process-wide. A new assignment replaces the previous observer; set
axGlobals.onUsage = undefinedduring test teardown or shutdown when appropriate. - In multi-process or serverless deployments, send events to a shared durable pipeline. Do not treat an in-memory total as application-wide accounting.
- Keep identifiers opaque and attributes low-cardinality. Avoid prompts, responses, secrets, and other sensitive payloads.
- Token events do not estimate currency cost. Apply a versioned provider/model pricing table downstream.
For direct AI calls and the complete event shape, also read ax-ai.
Actor Turn Callback
Use actorTurnCallback when the caller needs structured telemetry for each actor turn.
What it gives you:
code: the normalized JavaScript code the actor producedstage: which actor produced the turn (distillerorexecutor)result: the raw untruncated runtime return value from executing that codeoutput: the formatted action-log output string after Ax normalizes and truncates it for prompt replaythought: the actor model'sthoughtfield whenshowThoughtsis enabled and the provider returns oneexecutorResult: the full actor payload returned by the current actor stage, kept under this historical field name for compatibilityisError: whether the execution path for that turn was treated as an errorusage: token usage for this actor turn onlymodel: model used for this turn when explicitly set throughexecutorModelPolicychatLogMessages: raw ChatML conversation for this turn, populated only when an actor turn callback is set
Use it for:
- debug UIs that want to show code plus raw runtime results
- tracing and analytics
- capturing
thoughtfor internal diagnostics when supported by the provider - storing per-turn execution artifacts without scraping the prompt/action log
Important:
outputis not raw stdout; it is the formatted replay string used in the action log.resultis the raw runtime result before Ax applies type-aware serialization and budget-proportional truncation.thoughtis optional and only appears when the underlyingAxGencall hadshowThoughtsenabled and the provider actually returned a thought field.actionLogEntryCountandguidanceLogEntryCountreflect the live log sizes after the turn is processed, including resumed runs.actorTurnCallbackfires for the configured agent instance. Child agents passed throughfunctions: [...]should define their own callback if you need their internal actor turns; useonFunctionCallon the parent to observe the parent-side child-agent invocation.
Good pattern:
Callback type:
Context Event Observability
Use onContextEvent when the caller needs structured telemetry about prompt pressure and compaction. It does not change model behavior directly; it is for logs, evals, and dashboards.
Events:
budget_check: character-based prompt pressure before an actor turn, with detailed metrics kept out of the actor promptcheckpoint_created/checkpoint_cleared: checkpoint lifecycle events with covered turns and reasontombstone_created: compact resolved-error summary creationrelevance_ranking: emitted once per ranked domain per forward whenrelevanceRankingis enabled; carriesdomain('modules' | 'skills' | 'memories'), theshortlist({ id, score }[], most relevant first), andsuppressed(true when the low-confidence guard emitted no hint)field_auto_promoted: emitted once per field per run whenautoUpgradekeeps an oversized undeclared input value runtime-only; carriesfieldName,originalChars, andpromptPreviewChars(undefined when no inline preview was kept)
To measure whether the advisory hint helps, join per forward: relevance_ranking.shortlist ids against what the actor then loaded — for modules the internal discover calls (onFunctionCall with kind: 'internal', name: 'discover', args.request) plus the module part of external qualifiedNames; for skills onLoadedSkills / used(id); for memories onLoadedMemories / used(id).
Rules:
contextPressurein the actor prompt is intentionally compact (ok,watch,criticalplus one short instruction).- Budget metrics are character-based for provider neutrality and are exposed through
onContextEvent, not the actor prompt. - Callback errors are swallowed so telemetry cannot break the agent run.
- Do not scrape actor prompts for pressure metrics.
Type:
Agent Status Callback
Use agentStatusCallback when the caller wants real-time progress updates from the actor. When set, the actor can call await reportSuccess(message) and await reportFailure(message) in its JavaScript turns.
Rules:
agentStatusCallbackreceives(message: string, status: 'success' | 'failed').- When set, the actor prompt automatically includes
reportSuccess(message)andreportFailure(message)as available runtime functions. - The actor is instructed to keep the user updated on task progress.
reportSuccessandreportFailureare reserved runtime names when the callback is configured.- Child agents inherit the callback via the RLM config.
Type:
On Function Call
Use onFunctionCall when the caller wants to observe every function call the actor makes from the JS runtime. It fires before the underlying function runs.
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingwebsite/static/typescript/.well-known/agent-skills/ax-agent-observability/SKILL.md
Popularity
- Repository stars
- 2,957
- Repository forks
- 194
- 7-day trend score
- 40
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/ax-llm/ax/ax-agent-observability)