Skip to content

RLM: Simplify code#781

Merged
snimu merged 12 commits intomainfrom
sebastian/rlm-code-improvements-2026-01-24
Jan 24, 2026
Merged

RLM: Simplify code#781
snimu merged 12 commits intomainfrom
sebastian/rlm-code-improvements-2026-01-24

Conversation

@snimu
Copy link
Contributor

@snimu snimu commented Jan 24, 2026

Description

Simplifies RLM code without touching functionality.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Test improvement

Testing

  • All existing tests pass when running uv run pytest locally.
  • New tests have been added to cover the changes

Checklist

  • My code follows the style guidelines of this project as outlined in AGENTS.md
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

Note

Major internal cleanup with no intended behavior changes, focusing on maintainability and consistency.

  • Worker script generation: Replace large inline templates with _build_python_worker_script_template(sandboxed=...); extract reusable blocks (guardrails, FIFOs, FS context, jail); generate both local _RLM_WORKER_SCRIPT_TEMPLATE and sandbox _RLM_SANDBOX_PY_WORKER_SCRIPT_TEMPLATE from one source.
  • Env var setup: New _build_worker_env_vars() used by local and sandbox executors; toggles inclusion of code-exec restrictions.
  • Metrics: RLMMonitorRubric now auto-registers simple state metrics via a factory (_SIMPLE_METRICS, _make_state_metric); dynamic per-root-tool metrics retained.
  • REPL flow: Factor shared logic into _call_repl() and _maybe_add_context_warning(); call_python_repl appends execution time, call_bash_repl does not; warning text parameterized.
  • Tool docs/types: Introduce _append_tool_docs() to avoid duplication; annotate OAI tool lists with ChatCompletionFunctionToolParam; simplify root tool schema handling.
  • Sub-LLM accounting: Use _extract_tokens_from_response helper; llm_batch summary now shows prompt vs completion tokens separately; minor log/message tweaks.

Risk is primarily around template generation and executor env var changes affecting worker startup and token/metric reporting.

Written by Cursor Bugbot for commit c619cc8. This will update automatically on new commits. Configure here.

@snimu snimu changed the title Simplify code RLM: Simplify code Jan 24, 2026
@snimu snimu merged commit ffb4b2e into main Jan 24, 2026
6 checks passed
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