Skip to content

Conversation

@rawwerks
Copy link
Contributor

@rawwerks rawwerks commented Feb 2, 2026

Summary

This PR adds full depth>1 recursive subcall support for RLM, enabling nested RLM calls when code inside the REPL invokes llm_query().

Features

  • Recursive subcalls: _subcall() spawns child RLM instances with incremented depth
  • Uniform return type: _subcall() returns RLMChatCompletion (aligns with LM completion struct)
  • Budget/cost tracking: max_budget parameter with BudgetExceededError, OpenRouter cost extraction
  • Execution limits: max_timeout, max_tokens, max_errors with corresponding exceptions
  • Event callbacks: on_subcall_start, on_subcall_complete, on_iteration_start, on_iteration_complete

Files Changed

  • rlm/core/rlm.py - Core subcall logic, limits, callbacks
  • rlm/core/types.py - UsageSummary cost aggregation
  • rlm/environments/local_repl.py - subcall_fn integration
  • rlm/clients/openai.py - OpenRouter cost extraction
  • rlm/logger/verbose.py - Limit exceeded display
  • docs/getting-started.md, docs/api/rlm.md - Documentation

Tests

  • 13 unit tests for subcall behavior
  • 1 e2e test with google/gemini-3-flash-preview via OpenRouter
  • All 148+ existing tests pass

Breaking Changes

None - all existing APIs remain compatible.


🤖 Generated with Claude Code

rawwerks and others added 5 commits February 2, 2026 13:54
- Add max_budget parameter to RLM (in USD)
- Add BudgetExceededError exception
- Track cumulative cost across iterations
- Propagate remaining budget to child RLMs
- Add print_budget_exceeded to VerbosePrinter
- Export BudgetExceededError from rlm module

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant