Python exec tool for Ava

t-265.1·WorkTask·
·
·
Parent:t-265·Created2 months ago·Updated2 months ago

Description

Edit

Create a Python execution tool that allows Ava to run Python code snippets.

Context

Ava is a Telegram bot agent (Omni/Agent/Telegram.hs) that needs to execute Python code for data processing, API calls, and automation tasks as part of customer acquisition for PodcastItLater.

Requirements

1. Create Omni/Agent/Tools/Python.hs module 2. Tool name: python_exec 3. Execute Python snippets via subprocess 4. Capture stdout/stderr and return as result 5. Timeout after 30 seconds 6. Available stdlib: requests, json, csv, re, datetime, urllib

Tool Schema

{
  "name": "python_exec",
  "parameters": {
    "code": "string (required) - Python code to execute",
    "timeout": "integer (optional) - timeout in seconds, default 30"
  }
}

Implementation Notes

  • Use System.Process.readProcessWithExitCode
  • Write code to temp file, execute with python3
  • Clean up temp file after execution
  • Return JSON with stdout, stderr, exit_code fields
  • Follow patterns in Omni/Agent/Tools/Email.hs for tool structure

Testing

  • Add unit tests following Omni.Test patterns
  • Test: simple print statement
  • Test: import requests and make HTTP call
  • Test: timeout handling
  • Test: syntax error handling

Files to Modify

  • Create: Omni/Agent/Tools/Python.hs
  • Modify: Omni/Agent/Telegram.hs (add tool to telegram agent's tool list)

Verification

  • bild Omni/Agent/Tools/Python.hs
  • bild --test Omni/Agent/Tools/Python.hs

Timeline (2)

🔄[human]Open → InProgress2 months ago
🔄[human]InProgress → Done2 months ago