fix(rlm): reject sandbox name collisions - #70
Draft
isaacbmiller wants to merge 1 commit into
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
1. Issue / repro
RLM exposes signature inputs, user tools, and built-in helpers in one Python namespace, but currently accepts configurations where those names cannot coexist.
There are two independent collisions here:
firstbecause normalization uses last-write-wins dictionary construction;lookupinput overwrites the remaininglookuptool.Inputs can likewise shadow
print,SUBMIT,llm_query, orllm_query_batched. A tool namedforpassesstr.isidentifier()and fails only later when the sandbox tries to generate Python for it.2. Why this is the root cause
RLM currently validates each source of names in isolation:
That loses duplicate information before validation.
_validate_tools()then checks only tool identifiers and a few reserved tool names; it never compares tools with signature inputs, andisidentifier()alone accepts Python keywords.The runtime is behaving consistently: Python has one global name for
lookup. The invalid configuration should be rejected before RLM builds prompts that advertise both meanings.3. How we know the fix addresses the root cause
On untouched
mainat24ec85de4, the repro prints:That proves duplicate tools silently keep the second function, while
printas an input andlookupas both input and tool are accepted.This branch has constructor-level regressions for:
All fail at the boundary where the conflicting namespace is assembled.
4. Why this is the concise fix
Tool normalization now builds the dictionary explicitly so it can reject a duplicate before information is lost:
The existing tool validator becomes
_validate_namespace()and adds only the missing comparisons. There is no runtime renaming, precedence rule, alias map, or fallback lookup.5. Context needed to validate the change
The public RLM sandbox namespace contains:
llm_queryandllm_query_batched;SUBMITandprint.RLM's prompt tells the model those names are available simultaneously. If two sources use the same name, choosing a winner would make that prompt false. Renaming one side is the only configuration that preserves both capabilities.
6. What the fix does in the code
Compatibility boundaries and downsides
ValueError.Validation
uv run --frozen pytest -q tests/predict/test_rlm.py::TestRLMInitialization --deno—23 passeduv run --frozen pytest -q tests/predict/test_rlm.py --deno—116 passed, 2 skippedmain— fails withDID NOT RAISE ValueError; passes heresecond; input/helper and input/tool collisions construct successfully