npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@ravan08/pi-langfuse

v1.0.3

Published

Langfuse observability extension for Pi coding agent. Sends traces to Langfuse for monitoring tokens, costs, latency, and tool calls.

Downloads

349

Readme

@ravan08/pi-langfuse

npm version License: MIT

Langfuse observability extension for Pi Coding Agent. Sends traces to Langfuse for monitoring tokens, costs, latency, and tool calls.

Langfuse Trace Screenshot

Why Langfuse?

Langfuse provides open-source observability for LLM applications. This extension allows you to trace, monitor, and debug your Pi sessions with production-grade detail, helping you understand exactly how your agent is performing, what it's costing you, and where it might be failing.

Features

  • Hierarchical Tracing: Maps user prompts to per-turn spans and nested tool executions for deep visibility.
  • LLM Metadata: Automatically records model name, provider, token usage, and API costs per turn.
  • Tool Observability: Detailed logs for every tool call, including arguments, results, and error states.
  • Session Correlation: Groups all prompts from the same Pi session into a single Langfuse session.
  • Cost Tracking: Records input/output/total costs in USD per generation.
  • Token Usage: Tracks input and output tokens per turn.

Quick Install

Via npm (recommended)

pi install npm:@ravan08/pi-langfuse

Via git

pi install git:github.com/saravananravi08/pi-langfuse-extension

Configuration

Get your keys from Langfuse Cloud → Settings → API Keys.

Create config.json in the extension directory:

{
  "publicKey": "pk-lf-xxxx",
  "secretKey": "sk-lf-xxxx",
  "host": "https://cloud.langfuse.com"
}

For npm install, find the extension at:

~/.pi/agent/npm/@ravan08/pi-langfuse/index.ts

Usage

Run pi with tracing enabled

pi "your prompt"

Pi auto-loads the extension. All sessions will be traced to Langfuse.

Trace Model

Trace (name: "pi-agent")
├── Session ID: <pi-session-id>
├── Metadata: model, provider, cwd
└── Span (name: "tool:<name>")
    └── Input/Output logs

Generation (name: "llm-response")
├── Model: MiniMax-M2.7
├── Usage: input/output tokens
└── Cost: input/output/total USD

What Gets Tracked

Trace Level

  • input - User prompt
  • output - Assistant response
  • sessionId - Pi session identifier
  • metadata - Model, provider, cwd

Generation Observations (LLM Calls)

  • model - Model identifier (e.g., "MiniMax-M2.7")
  • usage - Token counts (input/output/total)
  • costDetails - Cost breakdown in USD

Span Observations (Tool Calls)

  • name - Tool name (e.g., "tool:bash")
  • input - Tool parameters (JSON)
  • output - Tool result
  • metadata.isError - Whether tool failed

Langfuse Dashboard

After running, check your Langfuse project for:

  1. Traces - All pi agent runs with I/O
  2. Sessions - Traces grouped by session ID
  3. Observations - Tool calls and LLM generations
  4. Scores - Token counts and costs
  5. Model Usage - Usage breakdown by model

Architecture

For a deep dive into the tracing model and data flow, see docs/architecture.md.

Troubleshooting

No traces appearing?

  • Verify API keys are correct in config.json
  • Check Langfuse project is active
  • Ensure API keys have write permissions

Extension not loading?

  • Run pi list to check installed packages
  • Try restarting pi

Model/cost not showing?

  • Not all providers expose cost info
  • Check Langfuse traces API for raw observation data

Dependencies

License

MIT