$ show lambda-calculus-LLM/lambda-RLM
This repository implements λ-RLM (Lambda Recursive Language Model), a framework for long-context reasoning that replaces free-form recursive code generation with a typed functional runtime grounded in λ-calculus. The system provides deterministic recursive decomposition, typed symbolic control flow, and bounded model calls at leaf subproblems. It features a modular architecture with pluggable LLM clients, sandboxed execution environments, and a benchmarking suite for comparison against standard RLM approaches. The core innovation is executing a pre-verified combinator chain (Φ) instead of open-ended LLM-driven while loops, guaranteeing termination and bounded cost.
The LLM identified 4 files worth highlighting for reuse:
The core λ-RLM implementation that replaces open-ended LLM recursion with a typed functional runtime. It implements Algorithm 1: λ-RLM Complete System with five phases (InitREPL, Task Detection, Optimal Planning, Cost Estimate, Execute Φ). The component demonstrates non-obvious skill in translating mathematical guarantees (termination, bounded cost) into executable code while maintaining a clean separation between symbolic control flow and neural inference at leaf nodes.
A multi-threaded socket server that routes LLM requests from the RLM process and environment subprocesses. It implements a clean 4-byte length prefix + JSON payload protocol and supports concurrent request handling, batched requests, and model-based routing. The component shows expertise in designing a robust inter-process communication layer that enables transparent scaling of LLM calls across different execution environments while maintaining strict usage tracking and error handling.
A local REPL environment with persistent Python namespace that executes code in a sandboxed namespace with access to context data. It implements safe builtins restrictions (blocking dangerous operations like eval/exec), custom tool support, persistent state management across calls, and context/history versioning. The component demonstrates advanced skill in creating a secure yet flexible execution environment that supports both simple variable storage and complex custom tool integration while preventing namespace corruption.
Communication utilities implementing a 4-byte big-endian length prefix + JSON payload protocol for communication between LMHandler and environment subprocesses. It provides typed request/response dataclasses (LMRequest, LMResponse) and helper functions for socket communication. The component exhibits clean design in defining a minimal, robust protocol that handles both single and batched requests while providing proper error handling and type safety.