Skip to content

awesomelyradical/rlm-controller

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

33 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

RLM Controller

A safe, policy-driven framework for processing extremely long inputs using Retrieval-augmented Long-context Memory (RLM) patterns.

Overview

RLM Controller enables LLM agents to process inputs that exceed typical context windows (50k+ characters) by:

  • Storing input as external context files
  • Intelligently slicing and searching content
  • Spawning parallel subcalls for analysis
  • Aggregating structured results with traceability

Features

  • 🧠 Smart Slicing: Keyword-based planning with fallback chunking
  • πŸ”’ Security-First: Prompt injection mitigation, no code execution, strict limits
  • ⚑ Parallel Execution: Async batch processing for speed
  • πŸ“Š Full Traceability: JSONL logging for every operation
  • 🎯 OpenClaw Native: Designed for OpenClaw agent framework

Quick Start

1. Store Long Input

python3 scripts/rlm_ctx.py store --infile input.txt --ctx-dir ./ctx

2. Generate Execution Plan

python3 scripts/rlm_auto.py \
  --ctx ./ctx/<ctx_id>.txt \
  --goal "analyze authentication logic" \
  --outdir ./run1

3. Create Async Batches (Optional)

python3 scripts/rlm_async_plan.py \
  --plan ./run1/plan.json \
  --batch-size 4 > ./run1/async_plan.json

python3 scripts/rlm_async_spawn.py \
  --async-plan ./run1/async_plan.json \
  --out ./run1/spawn.jsonl

4. Execute with OpenClaw

Use sessions_spawn to execute subcalls in parallel batches. See docs/flows.md for complete workflows.

Architecture

rlm-controller/
β”œβ”€β”€ scripts/           # Core utilities (~766 LOC)
β”‚   β”œβ”€β”€ rlm_ctx.py            # Context store/peek/search/chunk
β”‚   β”œβ”€β”€ rlm_plan.py           # Keyword-based slice planner
β”‚   β”œβ”€β”€ rlm_auto.py           # Auto artifact generator
β”‚   β”œβ”€β”€ rlm_async_plan.py     # Batch scheduler
β”‚   β”œβ”€β”€ rlm_async_spawn.py    # Spawn manifest builder
β”‚   β”œβ”€β”€ rlm_emit_toolcalls.py # Toolcall formatter
β”‚   β”œβ”€β”€ rlm_batch_runner.py   # Assistant-driven executor
β”‚   β”œβ”€β”€ rlm_runner.py         # JSONL orchestrator
β”‚   β”œβ”€β”€ rlm_trace_summary.py  # Log summarizer
β”‚   β”œβ”€β”€ rlm_path.py           # Shared path-validation helpers
β”‚   β”œβ”€β”€ rlm_redact.py         # Secret pattern redaction
β”‚   └── cleanup.sh            # Artifact cleanup
β”œβ”€β”€ docs/              # Documentation
β”‚   β”œβ”€β”€ flows.md              # Manual & async workflows
β”‚   β”œβ”€β”€ policy.md             # Limits & decision rules
β”‚   β”œβ”€β”€ security.md           # Security foundations
β”‚   β”œβ”€β”€ security_checklist.md # Pre/during/post run checks
β”‚   β”œβ”€β”€ security_audit_response.md # OpenClaw audit response
β”‚   └── cleanup_ignore.txt    # Cleanup exclusions
└── SKILL.md           # OpenClaw skill manifest

Security

RLM Controller is designed with security-first principles:

  • βœ… No code execution - Only safelisted helper scripts
  • βœ… Prompt injection mitigation - Input treated as data, not commands
  • βœ… Strict limits - Max recursion: 1, max subcalls: 32, max slice: 16k chars
  • βœ… Bounded work - Hard caps on batches and total slices
  • βœ… Least privilege - Subcalls read-only by design

See docs/security.md for detailed safeguards.

Use Cases

  • πŸ“š Large Documentation: Process entire codebases or API docs
  • πŸ“ Dense Logs: Analyze thousands of log lines for patterns
  • πŸ” Repository Analysis: Multi-file security audits
  • πŸ“Š Dataset Processing: Extract structured data from large files

Requirements

  • Python 3.7+
  • OpenClaw framework (for sessions_spawn integration)
  • Unix-like environment (bash scripts)

Configuration

Default policies can be customized in docs/policy.md:

  • Max subcalls: 32
  • Max slice size: 16k chars
  • Batch size: 4
  • Max recursion depth: 1

OpenClaw Integration

This skill integrates with the OpenClaw agent framework:

  • Uses sessions_spawn for parallel subcalls
  • Respects sub-agent constraints (no nested spawning)
  • Compatible with OpenClaw's tool safety model

Documentation

License

Licensed under the Apache License, Version 2.0. See LICENCE.md for details.

Contributing

Contributions welcome! Please:

  1. Review docs/security.md for security requirements
  2. Ensure all scripts pass basic smoke tests
  3. Update documentation for any new features
  4. Follow existing code style (Python PEP 8)

Project Status

Production Ready - Fully functional for OpenClaw deployments.

Future enhancements:

  • HTML trace viewer for log visualization
  • Direct LLM API integration (currently requires OpenClaw)
  • Additional output formats

Credits

Developed as part of the OpenClaw ecosystem for safe, scalable agent operations.

Sponsor this project

Contributors 3

  •  
  •  
  •