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

opencode-loop-guard

v0.1.1

Published

OpenCode plugin that stops a model from repeating the same tool call over and over

Downloads

539

Readme

opencode-loop-guard

An OpenCode 2.x plugin that stops a model from running the same tool call over and over.

Local models in long sessions sometimes get stuck re-running one command and re-reading the same result. OpenCode's built-in doom_loop check only catches repeated failures, so a call that keeps succeeding with the same output can loop a hundred times.

What it blocks

A tool call is refused when the same tool with the same input already returned the same result:

  • in each of the last two calls (a straight repeat), or
  • twice more among the last 10 calls (an A, B, A, B, A loop).

The model gets an error telling it to use the result it already has, take a different step, or ask the user. If it sends a blocked call 3 times in a row anyway, the guard ends the turn (OpenCode's session.interrupt), so a stuck model stops and waits for you instead of retrying for half an hour. Any call that runs resets that count. It's never blocked when:

  • the result changes between runs (polling until something finishes works), or
  • a file was edited since (edit, write, patch and similar tools start the count over, so "edit, re-run the tests, same failure, edit again" keeps working), or
  • the shell command waits or polls (sleep, wait, watch, *_status, unity … status).

Fields that don't change what a call does (description, timeout, title, reason) and key order are ignored when comparing inputs.

Install

Add it to opencode.json:

{ "plugins": ["opencode-loop-guard"] }

or copy index.js to ~/.config/opencode/plugins/loop-guard.js. Restart OpenCode.

Limits

  • It remembers the last 10 calls of up to 200 sessions, in memory only.
  • It relies on OpenCode 2.x's tool.hook("execute.before" | "execute.after") plugin API. Tested with OpenCode 2.1.4 and 2.3.2.

Development

npm test