akseljoonas HF Staff commited on
Commit
eee8002
·
1 Parent(s): 6d4d388

Use sandbox read endpoint for script resolution to avoid bash truncation

Browse files
Files changed (1) hide show
  1. agent/tools/sandbox_tool.py +8 -3
agent/tools/sandbox_tool.py CHANGED
@@ -12,7 +12,6 @@ a cpu-basic sandbox is auto-created (no approval needed).
12
  from __future__ import annotations
13
 
14
  import asyncio
15
- import shlex
16
  import threading
17
  from typing import Any
18
 
@@ -49,9 +48,15 @@ async def resolve_sandbox_script(
49
  if not sandbox or not _looks_like_path(script):
50
  return None, None
51
  try:
52
- result = await asyncio.to_thread(sandbox.bash, f"cat {shlex.quote(script)}")
 
53
  if result.success and result.output:
54
- return result.output, None
 
 
 
 
 
55
  return None, f"Failed to read {script} from sandbox: {result.error}"
56
  except Exception as e:
57
  return None, f"Failed to read {script} from sandbox: {e}"
 
12
  from __future__ import annotations
13
 
14
  import asyncio
 
15
  import threading
16
  from typing import Any
17
 
 
48
  if not sandbox or not _looks_like_path(script):
49
  return None, None
50
  try:
51
+ # Use the read endpoint instead of bash("cat ...") which truncates at 25KB.
52
+ result = await asyncio.to_thread(sandbox.read, script, limit=100_000)
53
  if result.success and result.output:
54
+ # Strip line number prefixes (read returns "N\tcontent" format)
55
+ lines = []
56
+ for line in result.output.split("\n"):
57
+ parts = line.split("\t", 1)
58
+ lines.append(parts[1] if len(parts) == 2 else line)
59
+ return "\n".join(lines), None
60
  return None, f"Failed to read {script} from sandbox: {result.error}"
61
  except Exception as e:
62
  return None, f"Failed to read {script} from sandbox: {e}"