Skip to content

feat(tools): PythonTool (run_python) — isolated venv Python execution - #35

Merged
ayman3000 merged 1 commit into
mainfrom
feat/python-tool
Jul 28, 2026
Merged

feat(tools): PythonTool (run_python) — isolated venv Python execution#35
ayman3000 merged 1 commit into
mainfrom
feat/python-tool

Conversation

@ayman3000

Copy link
Copy Markdown
Owner

Adds a first-class run_python tool to SwiftAgentKitTools, so on-device Python is a real capability instead of something the model orchestrates with raw shell commands.

PythonTool(venvPath:):

  • ensures the venv exists (creates it if missing),
  • pip-installs any requested packages into it (isolated from system Python),
  • stages the code to a temp file and runs it with the venv interpreter,
  • returns combined stdout/stderr + exit code.

requiresConfirmation (running code ≈ shell power), configurable venvPath/timeoutSeconds/maxOutputChars, wall-clock timeout (no pipe deadlock), macOS-only.

Tests

  • pythonToolRequiresConfirmation (hermetic).
  • pythonToolRunsInIsolatedVenv (gated live): creates a temp venv, runs print('PY_OK', 6*7)PY_OK 42, installs cowsay into the venv and imports it, and verifies the package is in the venv (not system Python). Passed ~4s. All 131 tests pass.

A first-class SwiftAgentKitTools tool that runs Python 3 in a dedicated venv:
ensures the venv exists, pip-installs requested `packages` into it (isolated
from system Python), stages `code` to a temp file, runs it with the venv
interpreter, and returns stdout/stderr + exit code. requiresConfirmation,
configurable venvPath/timeout/maxOutput, wall-clock timeout, macOS-only.

Replaces having the model orchestrate venv + pip via raw shell. Tests:
confirmation flag; gated live test creates a venv, installs cowsay into it,
runs code, and verifies the package landed in the venv (isolation).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@ayman3000
ayman3000 merged commit 46dbf98 into main Jul 28, 2026
1 check passed
@ayman3000
ayman3000 deleted the feat/python-tool branch July 28, 2026 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant