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

agentloop-langchain

v1.0.0

Published

AgentLoop integration for LangChain — earn up to 70% revenue share when your agent recommends relevant products.

Readme

agentloop-langchain

AgentLoop integration for LangChain. Earn up to 70% revenue share when your agent naturally recommends relevant products — with zero changes to your existing chains.

Install

npm install agentloop-langchain

Option 1 — Callback Handler (recommended)

Drop into any chain. Runs automatically after every LLM response.

import { AgentLoopCallbackHandler } from 'agentloop-langchain'
import { ChatOpenAI } from '@langchain/openai'
import { HumanMessage } from '@langchain/core/messages'

const agentloop = new AgentLoopCallbackHandler({
  apiKey: process.env.AGENTLOOP_API_KEY!,
  getUserId: () => hashUserId(session.userId), // hash it — never raw PII
})

// Add to any model, chain, or agent
const model = new ChatOpenAI({
  callbacks: [agentloop],
})

const response = await model.invoke([
  new HumanMessage('what tool should I use to monitor my LLM in production?')
])

// response.content already has the sponsored mention appended if relevant
console.log(response.content)

Works with any LangChain chain type:

// With LCEL chains
const chain = prompt.pipe(model).pipe(outputParser)
const result = await chain.invoke({ question }, { callbacks: [agentloop] })

// With ConversationChain
const conversation = new ConversationChain({ llm: model, callbacks: [agentloop] })

// With agents
const agent = createReactAgent({ llm: model, tools, prompt })
const executor = AgentExecutor.fromAgentAndTools({ agent, tools, callbacks: [agentloop] })

Option 2 — Tool (agent decides when to check)

Let the agent decide when to invoke AgentLoop, rather than automatically after every response.

import { AgentLoopTool } from 'agentloop-langchain'
import { createReactAgent, AgentExecutor } from 'langchain/agents'

const tools = [
  new AgentLoopTool({
    apiKey: process.env.AGENTLOOP_API_KEY!,
    getUserId: () => hashUserId(session.userId),
  }),
  // ...your other tools
]

const agent = createReactAgent({ llm, tools, prompt })
const executor = AgentExecutor.fromAgentAndTools({ agent, tools })

Configuration

new AgentLoopCallbackHandler({
  apiKey: string           // required — your AgentLoop API key
  getUserId?: () => string // recommended — return a hashed user ID per session
  contextWindow?: number   // how many messages to use as context (default: 5)
  debug?: boolean          // verbose logging (default: true in development)
})

How it works

  1. User sends a message to your agent
  2. Your agent generates a response via LangChain
  3. AgentLoop intercepts the response and scores it against active campaigns
  4. If relevance score > 70/100, a natural sponsored mention is appended
  5. You earn up to 70% of the CPC/CPL when the user clicks or converts

Guardrails built in:

  • Max 1 mention per conversation
  • Crisis/emergency conversations are never monetised
  • FTC-compliant "Sponsored mention via AgentLoop" disclosure on every mention
  • Fails silently — never breaks your chain

Get your API key

Sign up at agentloop.life → Dashboard → API Keys.

Free to join as an agent owner.