llamaIndex - 💡(How to fix) Fix ClawMoat integration: runtime security layer for LlamaIndex agents [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
run-llama/llama_index#21175Fetched 2026-04-08 01:41:16
View on GitHub
Comments
0
Participants
1
Timeline
1
Reactions
0
Author
Participants
Timeline (top)
closed ×1

Code Example

import { ClawMoat } from 'clawmoat';

const moat = new ClawMoat({ policy: 'standard' });

// Wrap any agent input/output
const result = await moat.scanInput(userQuery);
if (result.blocked) { /* handle */ }

const output = await agent.query(userQuery);
const outScan = await moat.scanOutput(output);
RAW_BUFFERClick to expand / collapse

Proposal: ClawMoat Security Integration

Hi LlamaIndex team — I'm the author of ClawMoat, an open-source runtime security layer for AI agents (npm, MIT, zero dependencies).

After RSAC 2026 this week (Zenity demo'd live exploitation of multiple enterprise AI agents) and the LiteLLM supply chain attack, I think there's a real gap between 'using an AI agent framework' and 'running it securely.'

What ClawMoat adds

import { ClawMoat } from 'clawmoat';

const moat = new ClawMoat({ policy: 'standard' });

// Wrap any agent input/output
const result = await moat.scanInput(userQuery);
if (result.blocked) { /* handle */ }

const output = await agent.query(userQuery);
const outScan = await moat.scanOutput(output);

Detects:

  • Prompt injection (13 patterns, session-aware)
  • Jailbreak attempts
  • Credential/secret leakage in outputs
  • Supply chain integrity issues
  • Unauthorized data sharing patterns

Integration approach

I'd like to build a LlamaIndex callback/instrumentation integration. Could be:

  1. A separate @clawmoat/llamaindex npm package
  2. A contributed integration in the LlamaIndex ecosystem

Would love guidance on the preferred integration pattern. Happy to submit a PR once we agree on the approach.

Refs: https://github.com/darfaz/clawmoat | https://clawmoat.com

extent analysis

Fix Plan

To integrate ClawMoat with LlamaIndex, we will create a separate npm package @clawmoat/llamaindex. Here are the steps:

  • Create a new npm package @clawmoat/llamaindex with the following dependencies:
    • clawmoat
    • llamaindex
  • Create a ClawMoat wrapper class that integrates with LlamaIndex:
// @clawmoat/llamaindex/index.js
import { ClawMoat } from 'clawmoat';
import { LlamaIndex } from 'llamaindex';

class ClawMoatLlamaIndex {
  constructor(policy = 'standard') {
    this.moaat = new ClawMoat({ policy });
    this.llamaIndex = new LlamaIndex();
  }

  async scanQuery(userQuery) {
    const result = await this.moaat.scanInput(userQuery);
    if (result.blocked) { /* handle */ }
    return this.llamaIndex.query(userQuery);
  }

  async scanOutput(output) {
    return this.moaat.scanOutput(output);
  }
}

export { ClawMoatLlamaIndex };
  • Use the ClawMoatLlamaIndex class in your application:
// example usage
import { ClawMoatLlamaIndex } from '@clawmoat/llamaindex';

const clawMoatLlamaIndex = new ClawMoatLlamaIndex();
const userQuery = 'example query';
const result = await clawMoatLlamaIndex.scanQuery(userQuery);
const output = await result;
const outScan = await clawMoatLlamaIndex.scanOutput(output);

Verification

To verify the integration, test the ClawMoatLlamaIndex class with various inputs and outputs, ensuring that it correctly detects and blocks malicious queries and outputs.

Extra Tips

  • Make sure to handle errors and blocked queries properly in your application.
  • Consider adding additional logging and monitoring to detect potential security issues.
  • Keep the clawmoat and llamaindex dependencies up to date to ensure you have the latest security patches and features.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING