You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 2fde0b2
Browse filesBrowse the repository at this point in the historyBrowse files
Two bugs caused the RLM to return wrong answers when a model called
FINAL() or FINAL_VAR() inside a ```repl``` code block:
1. Parser bug (utils/parsing.py): find_final_answer() ran its regex
over the raw response including fenced code blocks, so FINAL(x) in
a repl block was parsed as the terminal answer, returning the literal
string "final_answer" instead of its value.
Fix: strip all fenced code blocks before running the FINAL/FINAL_VAR
regex. FINAL/FINAL_VAR in prose still work as before.
2. Runtime bug (environments/local_repl.py, environments/base_env.py):
The system prompt advertises FINAL(value) as option 1 for submitting
a final answer, but FINAL was never injected into the REPL globals -
only FINAL_VAR was. Models calling FINAL() inside a repl block got a
NameError.
Fix: add _final() method to LocalREPL (mirrors _final_var for direct
values), inject it as globals["FINAL"], restore it in _restore_scaffold,
and add "FINAL" to RESERVED_TOOL_NAMES.
Tests added to TestFindFinalAnswer:
- test_final_inside_repl_code_block_not_parsed_as_terminal
- test_final_var_inside_repl_code_block_not_parsed_as_terminal
- test_final_in_prose_still_works_alongside_repl_block
- test_final_callable_in_repl_environment
Co-authored-by: Cursor <cursoragent@cursor.com>
0 commit comments