Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
Commit History
-
Turn Run agent into a real agentic loop with a workspace and tools
The page was a single LLM call with the whole SAP in the prompt. Now: - lib/tools.py: a Workspace sandboxed to one root, exposing list_files, read_file (line-paged), grep, write_file and run_r (Rscript with a timeout). Paths are confined chroot-style; traversal is rejected. - lib/agent_loop.py: the tool-use loop for both providers. The agent gets the document as a file (sap.txt/protocol.txt with page markers) instead of ~120K tokens of prompt, greps/reads it on demand, writes output.json + output.R into the workspace, and can run the R script and fix it before finishing. Tracks iterations, token usage and a full transcript, with an iteration cap. - Page: builds a temp workspace per run, streams each tool call to a live status log, collects the files the agent produced, and saves the transcript/usage alongside the outputs. - apt.txt installs r-base-core so run_r works on the Space; without R the tool says so and the agent continues. Verified with stubbed SDKs (no API …74239a8