LlamaIndex
AxonPushLlamaIndexHandler exposes explicit hooks for LlamaIndex.TS LLM, embedding, retriever, and query stages.
AxonPushLlamaIndexHandler is a set of plain instance methods you call at the
boundaries you care about. It does not auto-register with LlamaIndex’s
Settings or callbackManager, you wire each hook into the code that already
orchestrates retrieval and generation.
Tested against llamaindex@^0.8.
Install
npm install @axonpush/sdk llamaindex
Wire up the hooks
import { AxonPush, AxonPushLlamaIndexHandler } from "@axonpush/sdk";
const client = new AxonPush();
const handler = new AxonPushLlamaIndexHandler({
client,
channelId: process.env.AXONPUSH_CHANNEL_ID!,
agentId: "rag-pipeline",
});
handler.onQueryStart(question);
handler.onRetrieverStart(question);
const nodes = await retriever.retrieve(question);
handler.onRetrieverEnd(nodes.length);
handler.onLLMStart("gpt-4o", 1);
const response = await index.asQueryEngine().query(question);
handler.onLLMEnd(response);
handler.onQueryEnd(response);
For streaming, call handler.onLLMStream(token) per token.
agentId defaults to "llamaindex".
Method reference
| Method | Identifier | axonpush eventType | Payload |
|---|---|---|---|
onLLMStart(model?, promptCount?) | llm.start | agent.start | model, prompt_count |
onLLMEnd(output?) | llm.end | agent.end | truncated output |
onLLMStream(token) | llm.token | agent.llm.token | token |
onEmbeddingStart(model?, textCount?) | embedding.start | agent.tool_call.start | model, text_count |
onEmbeddingEnd(embeddingCount?) | embedding.end | agent.tool_call.end | embedding_count |
onRetrieverStart(query) | retriever.query | agent.tool_call.start | query |
onRetrieverEnd(nodeCount?) | retriever.result | agent.tool_call.end | node_count |
onQueryStart(query) | query.start | agent.start | query |
onQueryEnd(response?) | query.end | agent.end | truncated response |
Every argument is optional except the query strings. Omitted models record as
"unknown" and omitted counts as 0, so a partially-wired pipeline still
produces a readable trace.
Queries are cut to 500 characters; outputs and responses are JSON-serialised
and truncated at 500 characters, then run through the client’s redactor. Every
event carries metadata.framework: "llamaindex", and all of them share one
trace for the life of the handler, build a handler per request, or seed
traceId, if you want one trace per query rather than one per process.
Vercel AI SDK
axonPushMiddleware is a LanguageModelMiddleware for wrapLanguageModel, recording generateText and streamText calls with usage and finish reason.
Mastra
AxonPushMastraExporter plugs into Mastra 1.x observability and exports spans, logs, metrics, scores, and feedback with trace identity preserved.