🚧 LlamaIndex Integration Plugin for CSL-Core
📝 Context
CSL-Core provides a universal safety layer for AI agents via ChimeraPlugin in base.py.\ We currently support Lang, but LlamaIndex is heavily used for RAG-based agents and data engines.
To expand framework coverage, we need a lightweight plugin in:
chimera_core/plugins/llamaindex.py
This plugin must wrap LlamaIndex tools (starting with FunctionTool, optionally QueryEngineTool) so they cannot execute if a CSL policy is violated.
The enforcement lifecycle (normalize → verify → visualize) already exists in base.py.\ The LlamaIndex plugin should only implement the framework-specific interception layer.
🎯 Goal
Create:
GuardedLlamaTool
guard_tools() helper
Design philosophy must mirror the LangChain plugin:
- Composition over inheritance
- Fail-closed semantics
- Optional dependency
- Support for context injection and custom context mappers
🏗️ Implementation Requirements
1️⃣ Create Plugin File
chimera_core/plugins/llamaindex.py
2️⃣ Execution Interception (Critical)
LlamaIndex tools execute primarily through:
call(...)
acall(...)
__call__ (delegates to call)
The wrapper MUST:
- Intercept before execution
- Call
self._plugin.run_guard(tool_input, extra_context=...)
- Raise
ChimeraError on violation
- Only execute original tool if policy allows
Both sync and async paths must be supported.
3️⃣ Context Mapping
Default behavior:
tool_input = {
"args": args,
"kwargs": kwargs
}
Additionally: - Merge kwargs into the top-level context for ergonomic CSL variable matching. - Support optional context_mapper - Support optional inject - Support optional tool_field (inject tool name into context)
This ensures parity with the LangChain plugin.
4️⃣ Composition Over Inheritance
Use composition to wrap LlamaIndex tools. Do NOT subclass framework internals directly.
5️⃣ Optional Dependency
LlamaIndex must remain optional:
try:
from llama_index.core.tools import BaseTool
except ImportError:
raise ImportError(
"LlamaIndex required. Install with: pip install llama-index-core"
)
🧪 Tests
Add:
tests/integration/test_llamaindex.py
Test scenarios:
- ✅ Allowed tool call executes normally
- ❌ Policy violation raises
ChimeraError
- ❌ Tool is NOT executed when blocked
- ✅ Custom
context_mapper works
- ✅ Async
acall is enforced
📦 Example
Add demo:
examples/integrations/llamaindex_agent_demo.py
Demonstrate:
- Simple
FunctionTool
- Basic CSL policy
- Block + allow cases
✅ Acceptance Criteria
🔐 Security Model
- Fail-closed
- Deterministic enforcement
- No execution before verification
- Consistent lifecycle with
ChimeraPlugin
🚀 Why This Matters
LlamaIndex is widely used for RAG agents and data-driven AI systems.
Adding this plugin:
- Expands CSL-Core's ecosystem reach
- Strengthens "Universal Safety Layer" positioning
- Keeps enforcement consistent across AI frameworks
- Moves toward framework-agnostic AI governance
🚧 LlamaIndex Integration Plugin for CSL-Core
📝 Context
CSL-Core provides a universal safety layer for AI agents via
ChimeraPlugininbase.py.\ We currently support Lang, but LlamaIndex is heavily used for RAG-based agents and data engines.To expand framework coverage, we need a lightweight plugin in:
This plugin must wrap LlamaIndex tools (starting with
FunctionTool, optionallyQueryEngineTool) so they cannot execute if a CSL policy is violated.The enforcement lifecycle (
normalize → verify → visualize) already exists inbase.py.\ The LlamaIndex plugin should only implement the framework-specific interception layer.🎯 Goal
Create:
GuardedLlamaToolguard_tools()helperDesign philosophy must mirror the LangChain plugin:
🏗️ Implementation Requirements
1️⃣ Create Plugin File
2️⃣ Execution Interception (Critical)
LlamaIndex tools execute primarily through:
call(...)acall(...)__call__(delegates tocall)The wrapper MUST:
self._plugin.run_guard(tool_input, extra_context=...)ChimeraErroron violationBoth sync and async paths must be supported.
3️⃣ Context Mapping
Default behavior:
Additionally: - Merge
kwargsinto the top-level context for ergonomic CSL variable matching. - Support optionalcontext_mapper- Support optionalinject- Support optionaltool_field(inject tool name into context)This ensures parity with the LangChain plugin.
4️⃣ Composition Over Inheritance
Use composition to wrap LlamaIndex tools. Do NOT subclass framework internals directly.
5️⃣ Optional Dependency
LlamaIndex must remain optional:
🧪 Tests
Add:
Test scenarios:
ChimeraErrorcontext_mapperworksacallis enforced📦 Example
Add demo:
Demonstrate:
FunctionTool✅ Acceptance Criteria
chimera_core/plugins/llamaindex.pycreatedguard_tools()APIChimeraErroron violation🔐 Security Model
ChimeraPlugin🚀 Why This Matters
LlamaIndex is widely used for RAG agents and data-driven AI systems.
Adding this plugin: