#2603·LangBot

[Bug]: Native Box file tools fail when sandbox python points to Python 2

Author: huanghuoguoguoCreated Sep 27, 2026Updated Sep 27, 2026

Runtime environment

  • LangBot Community Edition v4.11.0b3, source deployment; Core runs in a Python 3.11 virtual environment
  • Linux x86_64, local nsjail Box backend (nsjail 3.6, langbot-plugin 0.6.19)
  • On the host, unversioned python is 2.7.18 and python3 is 3.8.17
  • LocalAgent with a function-calling model and Box enabled

Exception

After the Box process-limit problem tracked in #2602 was avoided for QA, a real LocalAgent native exec call completed in nsjail with exit code 0. Exec also wrote a file under /workspace and its content was verified. Native file tools still failed:

  • write: four calls returned a Python SyntaxError at the generated f-string in the "invalid base64 content" branch; no write completed.
  • read: one call returned a Python SyntaxError at the generated "File not found" f-string.

The native tool path returns these as tool results with ok=false. This failure occurs before file I/O, so it is separate from nsjail mount permissions.

Reproduction steps

  1. Deploy LangBot with the local nsjail Box backend on a Linux host where python resolves to Python 2, while Core itself runs with Python 3 and python3 is available.
  2. Confirm that a native exec command works in Box.
  3. Ask LocalAgent to use native write and read on a /workspace file.
  4. Inspect the tool results; both scripts fail to parse under Python 2.

The Core file-tool fallback launches a generated script with unversioned python. The generated scripts contain Python 3 syntax and APIs. Nsjail mounts the host /usr and /bin read-only, so the host's interpreter choice is visible in the sandbox. The Core Python version does not determine what the command python resolves to there.

Expected behavior and discussion

Native file tools should either use a supported Python 3 interpreter in the Box environment or report a clear missing/interpreter-version prerequisite before exposing tools that cannot run. What interpreter contract should local nsjail Box have, and should Box/tool readiness validate it?

A useful regression case would keep python pointing to Python 2 and python3 available on the host, then verify native write/read round-trip through LocalAgent and the CLI. The other file tools sharing this script runner (edit/glob/grep) should be covered as well.