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

@roelven/openclaw-sanitize-tool-results

v1.0.1

Published

OpenClaw plugin that sanitizes tool results — fixes malformed tool blocks, truncates oversized results, strips ANSI codes

Readme

sanitize-tool-results

An OpenClaw plugin that prevents session corruption by cleaning up malformed tool blocks before they get persisted to the conversation history.

What it does

When an agent session runs, every tool call and its result gets saved to the conversation transcript. Occasionally, tool results arrive malformed — a missing ID, a missing tool name, oversized output from a verbose command, or ANSI color codes from terminal output. If these get persisted as-is, they can confuse the LLM on subsequent turns or break session replay.

This plugin intercepts messages before they are written to the transcript and fixes three categories of problems:

  1. Malformed tool call blocks — If a tool call is missing its id, name, or arguments, the plugin fills in safe defaults (a generated UUID, __unknown_tool, or {}) and logs a warning.
  2. Oversized results — Tool output larger than 100 KB is truncated to 100 KB with a [TRUNCATED] notice appended. This prevents a single large cat or exec output from bloating the context window.
  3. ANSI escape codes — Terminal color codes (\x1b[32m, etc.) are stripped so the LLM sees clean text.

The plugin only modifies what gets persisted — it does not change what the LLM sees in real time. This makes it safe to run alongside other plugins.

Why use it

  • Prevents rare but hard-to-debug session corruption from malformed tool blocks
  • Keeps conversation transcripts clean and replayable
  • Avoids context window waste from oversized tool output
  • Zero configuration, zero overhead for normal-sized results

Compatibility

  • OpenClaw version: Requires OpenClaw main branch (post-February 2026) with the plugin hook system wired.
  • Hook used: tool_result_persist — this hook is part of the standard plugin API and does not require any core modifications.
  • No external dependencies.

Installation

openclaw plugins install @roelven/openclaw-sanitize-tool-results

Then register it in your ~/.openclaw/openclaw.json:

{
  "plugins": {
    "allow": ["sanitize-tool-results"],
    "entries": {
      "sanitize-tool-results": { "enabled": true }
    }
  }
}

Restart the gateway:

openclaw gateway stop && openclaw gateway start

Setup

No additional setup is needed. The plugin works out of the box with sensible defaults:

  • Max result size: 100 KB
  • ANSI stripping: always on
  • Malformed block repair: always on

There is nothing the user or the agent needs to configure after installation.

License

MIT