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

langchain-aws-utils

v1.2.13

Published

Utilities and helpers for LangChain and LangGraph with AWS services

Readme

langchain-aws-utils

npm package Build Status Downloads Issues Dependencies Commitizen Friendly Semantic Release

Utilities and helpers for LangChain and LangGraph with AWS services

Install

npm install langchain-aws-utils

or

yarn add langchain-aws-utils

Usage

Guardrails

import { isGuardrailStopped } from 'langchain-aws-utils/guardrails';

// Check if an LLM result was stopped by guardrails
const llOutput = await model.invoke(messages);
const isStopped = isGuardrailStopped(llOutput);

if (isStopped) {
  console.log('LLM result was stopped by guardrails');
}

Memory Management

import { cleanMemoryFromBlockedMessages } from 'langchain-aws-utils/memory';
// Clean memory checkpoint from blocked messages
const { cleanedData, shouldOverride } = cleanMemoryFromBlockedMessages(memoryCheckpoint);

if (shouldOverride) {
  // Update your memory with the cleaned data
  await updateMemory(cleanedData);
}

API

Guardrails

isGuardrailStopped(llOutput)

Check if an LLM result was stopped by guardrails. This function examines the LLM result object to determine if guardrails intervened during execution.

Parameters:

  • llOutput (LLMResult): The LLM result object to check, usually from a LangGraph node callback

Returns: boolean - True if the LLM result was stopped by guardrails

Example:

// In a LangGraph node callback
async handleLLMEnd(llOutput: LLMResult): Promise<any> {
  const isStopped = isGuardrailStopped(llOutput);
  if (isStopped) {
    console.log('LLM result was stopped by guardrails');
  }
}

Memory Management

cleanMemoryFromBlockedMessages(memoryCheckpoint)

Cleans memory checkpoint traces by removing messages that were blocked by guardrails. This function filters out blocked assistant messages and their causative human messages to maintain clean conversation memory.

Parameters:

  • memoryCheckpoint (unknown): The memory checkpoint trace object to clean

Returns: { cleanedData: CheckpointTuple; shouldOverride: boolean }

  • cleanedData: The cleaned checkpoint data with blocked messages removed
  • shouldOverride: Whether the memory should be updated with the cleaned data

Example:

// Clean memory from blocked messages
const { cleanedData, shouldOverride } = cleanMemoryFromBlockedMessages(memoryCheckpoint);

if (shouldOverride) {
  // Update your LangGraph memory with the cleaned data
  await graph.updateState(cleanedData);
}

What it removes:

  • Assistant messages that were blocked by guardrails (detected by stop reasons like "blocked" or "guardrail_intervened")
  • The causative human messages that led to the blocked assistant responses
  • Maintains conversation flow by removing the problematic interaction pairs

Use cases:

  • Clean conversation memory after guardrail interventions
  • Remove blocked content from chat history
  • Maintain clean conversation state in LangGraph applications