examples: add RLM (Recursive Language Model) demo#1778
Conversation
Implement the RLM paper (arXiv:2512.24601) in Go using: - HTTP service architecture for centralized LLM proxying and recursive orchestration - Starlark (Python subset) REPL for LLM-generated code execution - Symbolic recursion via rlm_query spawning child RLM instances - Concurrent batch operations (llm_query_batched, rlm_query_batched) - Depth/iteration budget awareness in prompts for LLM self-planning WIP: needs integration testing with real LLM endpoints. Co-authored-by: Cursor <[email protected]>
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| // Detach from HTTP request lifecycle — recursive RLM calls can be long-running. | ||
| ctx := context.WithoutCancel(r.Context()) | ||
|
|
||
| if req.Depth >= s.maxDepth { |
There was a problem hiding this comment.
maxDepth=1 never runs a child RLM because Depth reaches 1 before this check. Use req.Depth > s.maxDepth here so one configured recursive level executes.
中文
`maxDepth=1` 不会运行子级 RLM,因为检查前 `Depth` 已经变成 1。这里改为 `req.Depth > s.maxDepth`,让配置的一级递归实际执行。
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1778 +/- ##
===================================================
+ Coverage 89.77574% 89.77838% +0.00263%
===================================================
Files 936 936
Lines 151610 151610
===================================================
+ Hits 136109 136113 +4
+ Misses 9770 9769 -1
+ Partials 5731 5728 -3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Major refactoring of the RLM example: - Restructure into examples/rlm/simple/ subdirectory - Refactor iterative loop to ReAct agent pattern (tool calling) - Add rate limiter (token-bucket, default 20 QPM) - Add exponential backoff retry for 429 errors - Remove direct rlm_query tool; enforce Starlark-based delegation - Enrich sub-agent context with RootQuery and structured metadata - Auto-clone EbookFoundation/free-programming-books as demo data - Add README with architecture docs and usage instructions - Fix HTTP client timeout (5min -> 30min) for long-running sub-agents Addresses review feedback: - maxDepth boundary check is now handled via canRecurse in prompt/tools (depth < maxDepth), not as a hard guard in service handler Co-authored-by: Cursor <[email protected]>
Summary
Implement the RLM paper (arXiv:2512.24601) as a Go example demonstrating how LLMs can process very large documents via recursive code-driven decomposition.
Architecture
execute_code+final_answertoolscontextrlm_query()spawns child RLM instances via HTTPrlm_query_batched/llm_query_batchedfor parallel executionFile Structure
Demo
The example auto-clones EbookFoundation/free-programming-books, currently loading about 2.2M chars across 200+ markdown files, and identifies outdated/deprecated content:
Key Design Decisions
rlm_queryis called from Starlark so child contexts are explicit slices produced by codeValidation
cd examples/rlm && go test ./...