@linnify/agentlens-pi

AgentLens extension for the pi coding agent: traces prompts, model calls and tool calls

Packages

Package details

extension

Install @linnify/agentlens-pi from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:@linnify/agentlens-pi
Package
@linnify/agentlens-pi
Version
0.7.0
Published
Nov 4, 2026
Downloads
889/mo · 889/wk
Author
razvanbretoiu
License
SEE LICENSE IN LICENSE
Types
extension
Size
40.4 KB
Dependencies
4 dependencies · 1 peer
Pi manifest JSON
{
  "extensions": [
    "./dist/index.js"
  ]
}

Security note

Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.

README

@linnify/agentlens-pi

A pi extension that sends every prompt pi runs to AgentLens as one trace:

pi AgentLens
A prompt, from before_agent_start until the run settles The trace, rooted at an agent span named pi: the user's prompt in, the last answer out
A model call A generation with the prompt (system prompt and conversation), the reply, the model, its parameters and thinking level, token usage and pi's cost
A tool call (read, bash, edit, an extension's tool…) A tool span with its arguments and result
A compaction during a run A compaction generation
The pi session The trace's session

Tokens and cost are pi's own, the same for any provider or gateway: the usage the provider reported and the cost pi works out from the model's prices. A model pi has no prices for reports no cost, and AgentLens prices it from the usage. A tool that calls a model itself and reports its usage in its result, such as a subagent, gets a generation under its span.

Install

pi install npm:@linnify/agentlens-pi        # for every project
pi install -l npm:@linnify/agentlens-pi     # for this project, in .pi/settings.json
pi -e npm:@linnify/agentlens-pi             # for one run

An app that ships pi with its own extensions can bundle it as one of them: export { default } from '@linnify/agentlens-pi';.

Configure

Everything comes from the environment, so the same extension serves every agent:

Variable
AGENTLENS_API_KEY Required. An API key of the project the agent belongs to
AGENTLENS_ENABLED false, 0, no or off turns the extension off, silently. On by default
AGENTLENS_AGENT Required. The agent the traces belong to, e.g. builder
AGENTLENS_BASE_URL Defaults to https://api.agentlens.linnify.com
AGENTLENS_SESSION_ID The trace's session; pi's session id when unset
AGENTLENS_USER_ID The user the traces are for
AGENTLENS_TENANT The tenant the traces belong to
AGENTLENS_ENVIRONMENT e.g. production
AGENTLENS_METADATA A JSON object added to the metadata of every trace's root span, e.g. {"ticket":"SF-12","branch":"feat/x"}. A value that is not a JSON object is left out, with a warning

Without an API key or an agent nothing is sent: the footer reads agentlens: off, or a warning is logged when pi runs without its interface (--print, --mode rpc).

Traces are flushed when each run settles, so a pi process that exits right after its prompt still delivers them.