Repository navigation
Keeping Python variables across smolagents steps in a sandbox #3319
carrollco
started this conversation in
Show and tell
Replies: 1 comment 1 reply
|
Nice demo. For CodeAgent the state that tends to matter goes beyond plain variables: the working directory and files written mid-run, modules imported with config set at import time, and loaded dataframes or model objects that are expensive to rebuild. Stopping when the session is lost is the honest default. A middle ground could be having the executor record the cells it ran, so after a lost session it can replay them in a fresh interpreter, behind a flag, since replaying cells with side effects (HTTP calls, writes) isn't safe. Do you checkpoint at all, or is the session strictly in memory? |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
If a smolagents CodeAgent defines a Python variable in one step, the next step needs to see it. I built a Plimsoll executor that keeps one Python interpreter running across steps in a sandbox you host.
The demo sets
answer = 6 * 7in step one and callsfinal_answer(answer)in step two. Finding out whether a variable survived is about as much suspense as I want from a multiplication problem. If the sandbox session is lost, the agent stops. The example includes local setup and uses scripted replies, so it makes no model API calls.If you run CodeAgent in a sandbox, what state does your agent need to keep between steps?
Example with setup and run commands
All reactions