From 49b8285c73fe685dfce0272b9a02a52e9b39aee0 Mon Sep 17 00:00:00 2001 From: Petar Zivkovic Date: Thu, 5 Mar 2026 22:06:11 +0100 Subject: [PATCH] feat(agent): remove unneeded python_execution tool --- .../function_calling/python_execution.py | 54 ------------------- skills/python-scratchpad/SKILL.md | 11 ++-- .../python-scratchpad/references/examples.md | 2 +- yaml_instance/skills.yaml | 6 +-- 4 files changed, 9 insertions(+), 64 deletions(-) delete mode 100644 functions/function_calling/python_execution.py diff --git a/functions/function_calling/python_execution.py b/functions/function_calling/python_execution.py deleted file mode 100644 index fcb63465..00000000 --- a/functions/function_calling/python_execution.py +++ /dev/null @@ -1,54 +0,0 @@ -def run_python_script(script: str, timeout_seconds: int = 60) -> dict: - """ - Run a short Python script and return a structured result with stdout, stderr, and exit code. - - This tool is intended for agent workflows that need a reliable Python scratchpad for - calculations, parsing, formatting, or quick validation. - """ - import os - import subprocess - import sys - import uuid - from pathlib import Path - - workspace = Path(os.getenv("TEMP_CODE_DIR", "temp")).resolve() - workspace.mkdir(exist_ok=True) - - script_path = workspace / f"{uuid.uuid4()}.py" - payload = script if script.endswith("\n") else script + "\n" - script_path.write_text(payload, encoding="utf-8") - - try: - completed = subprocess.run( - [sys.executable or "python3", str(script_path.resolve())], - cwd=str(workspace), - capture_output=True, - text=True, - timeout=timeout_seconds, - check=False, - ) - return { - "ok": completed.returncode == 0, - "exit_code": completed.returncode, - "stdout": completed.stdout, - "stderr": completed.stderr, - } - except subprocess.TimeoutExpired as exc: - return { - "ok": False, - "exit_code": None, - "stdout": exc.stdout or "", - "stderr": (exc.stderr or "") + f"\nError: Execution timed out after {timeout_seconds} seconds.", - } - except Exception as exc: - return { - "ok": False, - "exit_code": None, - "stdout": "", - "stderr": f"Execution error: {exc}", - } - finally: - try: - script_path.unlink(missing_ok=True) - except Exception: - pass diff --git a/skills/python-scratchpad/SKILL.md b/skills/python-scratchpad/SKILL.md index 33c42d37..638a0122 100644 --- a/skills/python-scratchpad/SKILL.md +++ b/skills/python-scratchpad/SKILL.md @@ -1,7 +1,7 @@ --- name: python-scratchpad description: Use the existing Python execution tools as a scratchpad for calculations, data transformation, and quick script-based validation. -allowed-tools: run_python_script execute_code +allowed-tools: execute_code --- # Python Scratchpad @@ -15,22 +15,21 @@ This skill is especially useful for: - checking assumptions with a small reproducible script Requirements: -- The agent should have access to `run_python_script` or `execute_code`. +- The agent should have access to `execute_code`. Workflow: 1. If the task needs computation or a repeatable transformation, activate this skill. 2. If you need examples, call `read_skill_file` for `references/examples.md`. 3. Write a short Python script for the exact task. 4. Prefer `run_python_script` with the script in its `script` argument. -5. If `run_python_script` is unavailable, call `execute_code` once with that script. -6. Use the script output in the final answer. -7. Keep scripts small and task-specific. +5. Use the script output in the final answer. +6. Keep scripts small and task-specific. Rules: 1. Prefer standard library Python. 2. Print only the values you need. 3. Do not invent outputs without running the script. -4. If neither `run_python_script` nor `execute_code` is available, say exactly: `No Python execution tool is configured for this agent.` +4. If `execute_code` is not available, say exactly: `No Python execution tool is configured for this agent.` 5. Do not claim there is a generic execution-environment problem unless a tool call actually returned such an error. Expected behavior: diff --git a/skills/python-scratchpad/references/examples.md b/skills/python-scratchpad/references/examples.md index 4aecc9d5..611d315e 100644 --- a/skills/python-scratchpad/references/examples.md +++ b/skills/python-scratchpad/references/examples.md @@ -7,7 +7,7 @@ numbers = [14, 27, 31, 8] print(sum(numbers)) ``` -Expected structured result with `run_python_script`: +Expected structured result with `execute_code`: ```json { diff --git a/yaml_instance/skills.yaml b/yaml_instance/skills.yaml index d47b2de3..23ab4287 100644 --- a/yaml_instance/skills.yaml +++ b/yaml_instance/skills.yaml @@ -1,6 +1,7 @@ graph: id: skills - description: '' + description: Workflow to demonstrate skills usage + initial_instruction: Give the agent an instruction to explicitly use code to generate a Fibonacci sequence, sum numbers, or something else that is better done with code than LLM generation. log_level: DEBUG is_majority_voting: false nodes: @@ -17,7 +18,7 @@ graph: - type: function config: tools: - - name: python_execution:All + - name: code_executor:All timeout: null prefix: '' thinking: null @@ -33,7 +34,6 @@ graph: log_output: true edges: [] memory: [] - initial_instruction: '' start: - Qwerty end: []