Repository navigation
Conversation
munimthahmid
left a comment
There was a problem hiding this comment.
@W-OK-E I tested this through the SREGym CLI, and the intended persistence works well for exported variables, shell functions, and the working directory. I found two issues and left inline comments about them. Could you please address them? Otherwise, the feature looks good.
| # If a cwd is explicitly requested, it wins over the persisted directory. | ||
| start_dir = shlex.quote(cwd) if cwd else "." | ||
| # Restore prior state -> run the user's command -> snapshot exported vars, functions, | ||
| # and cwd for the next call. The user command's own exit code is preserved via exit. | ||
| wrapped = ( | ||
| f"[ -f {state} ] && source {state} 2>/dev/null; " | ||
| f"cd {start_dir} 2>/dev/null; " |
There was a problem hiding this comment.
This issue will not block the current SREGym CLI, so it is minor, but it should still be fixed.
For example, after Shell.exec("cd /tmp"), calling Shell.exec("pwd", cwd="tests") should run in <repo>/tests, but it returns /tmp. The persisted /tmp state is restored before the relative cwd is applied, so tests is resolved as /tmp/tests. Since that directory does not exist and the cd error is suppressed, the command remains in /tmp.
This also contradicts the comment above, which says that an explicitly requested cwd wins over the persisted directory.
There was a problem hiding this comment.
Patched - resolves to absolute cwd not relative.
|
Hello @munimthahmid ! Thank you for reviewing the PR and the suggestions, I have made a few changes w.r.t the points raised. Kindly review them and let me know if it seems fine. |
There was a problem hiding this comment.
Seems like you mistakenly added the problem from #883 here. Can you remove it from this PR?
|
Sincere apologies @munimthahmid again! Will be careful handling multiple work-trees hereon. |
68e7a93 to
93ab29b
Compare
|
I should be apologizing @munimthahmid. Have closed this since the current worktree is a mess. Primarily due to the hacks I was doing to test #883 on my NAS. I will create a new PR. Apologies for the inconvenience. |
This PR emerges from the discussions in #883 and #898 to enable shell-state persistence across
SREGym>cli commands used for debugging.What Changed
Shell.execnow persists exported variables, shell functions, and the working directory across successiveSREGym>CLI commands, so a sequence of commands behaves like one interactive shell session:Previously each command ran in a fresh
bashwith no memory of the last one, soexport, functions, andcdwere lost between commands.How it works
After each command we snapshot the exported environment (
declare -px), function (declare -pf), and$PWDto a per-process state file (one per CLI PID, the temp dir), and source it before the next command. Each command still runs inits own short-lived
bashprocess; the state file is what carries context forward.Scope
Dev/debug CLI only —
cli.pyis unchanged; it simply callsShell.exec. No behavior change formain.py/ agent runs. The change lives entirely in `shell.pyOne simple thing to point out - The changes only take place AFTER the debug shell has entered into a problem session i.e. after
start <problem-idhas executed sincecli.pyholds the session in a while loop checking for thestartandexitcommands.Let me know if this seems fine or if any changes are required.
Also, apologies for the delay in #883 @Saadmrp1038, I had hooked up a RAID HDD to run the local evaluations and it failed so kind of working things out there, but it will be done soon too.