May 19th, 2026

Got Python Code? Reuse It Now

Turn your existing Python code into an agent skill without redesigning. Execute your functions whenever you need.

We've made it simpler for your agents to execute your custom Python functions as reusable skills. Define your Python function once with fixed parameters and business logic, and let your agents call it whenever they need, perfect for production workflows, API integrations, and repetitive tasks that need consistency.

Python Code Execution Skill

Your agents can now run custom Python functions you've predefined, turning any well-defined Python logic into a reliable agent skill. Whether it's currency conversion, data validation, complex calculations, or API integration, your agents execute your exact code every time: no surprises, no dynamic code generation.

What you can do:

  • Define once, execute many times: Write a Python function with fixed parameters and business rules, then let your agents call it repeatedly with confidence

  • Production-ready workflows: Use consistent, tested code for critical operations like currency conversion, payment processing, or data validation

  • API integration: Wrap external API calls with authentication, error handling, and response parsing built-in

  • Data transformation: Normalize, validate, and transform user input or external data with your exact specifications

  • Complex calculations: Implement business rules (bulk discounts, zone-based pricing, tax calculations) with full control

  • Scheduled operations: Integrate with your existing systems reliably, knowing the code won't change between executions

How it works:

  1. You write a Python function with fixed parameters and return logic

  2. You define the parameters your function accepts (name, type, description)

  3. You add the Python Code Execution skill to your agent

  4. Your agent calls that skill with the right parameters, and gets consistent results

  5. Results are returned and used in the agent's next action

Technical details:

  • Language: Python 3.x

  • Available libraries: requests, pandas, numpy, json, datetime, math, re, collections, itertools, and more

  • Execution environment: Isolated sandbox for security

  • Timeout: Configurable per execution (default varies by plan)

  • Memory limit: Per-execution limits apply

  • Parameter definition: You define fixed parameters in JSON format with name, type, and description

  • Error handling: Use try-except blocks to gracefully handle errors and return helpful messages

Setup requirements:

  • Tool name (descriptive identifier)

  • Skill description (when the agent should use it)

  • Python packages (if needed, comma-separated)

  • Function parameters (JSON format with name, type, and description)

  • Python code (your complete function definition)

Availability:

  • Pro plan and higher (Team Starter, Team Growth, Custom)

  • Not available on the free plan

Where to find it: Agents → [Your Agent Name] → Edit → Skills → Add a skill → "Python Code Execution"

Python Code Execution vs. Python Code Interpreter: Which one to use?

We also offer Python Code Interpreter for different use cases. Here's how to choose:

Aspect

Python Code Execution

Setup

More detailed (5+ fields)

Simple (2 fields)

Best for

Repetitive, well-defined tasks

Ad-hoc, flexible requests

Function definition

You define it upfront

Agent generates it dynamically

Parameters

Fixed, predefined

Flexible, request-based

Use cases

Production workflows, APIs, data validation

Exploratory analysis, one-off tasks, dynamic calculations

Use Python Code Execution when:

  • You need consistent, tested code for production workflows

  • Your function has fixed parameters and predictable inputs

  • You're building integrations with external APIs

  • You want full control over error handling and business logic

Use Python Code Interpreter when:

  • Your agent needs to generate code on-the-fly for different requests

  • You're doing exploratory data analysis or ad-hoc calculations

  • Parameters vary significantly between requests

  • You want maximum flexibility without predefined structure

How to test this feature

  1. Open an existing agent or create a new one

  2. Go to Skills and click Add a skill

  3. Search for and select "Python Code Execution"

  4. Fill in the details:

    • Tool Name: "Currency Converter" (or your use case)

    • Skill Description: "Used to convert amounts between different currencies using live exchange rates"

    • Python Packages: requests (if needed)

    • Python Function Parameters:

      { "amount": { "name": "amount", "type": "float", "description": "The amount to convert" }, "from_currency": { "name": "from_currency", "type": "str", "description": "Source currency code (e.g. USD)" }, "to_currency": { "name": "to_currency", "type": "str", "description": "Target currency code (e.g. EUR)" } } 
    • Python Code:

      import requests def convert_currency(amount: float, from_currency: str, to_currency: str) -> str: url = f"https://api.frankfurter.app/latest?amount={amount}&from={from_currency}&to={to_currency}" response = requests.get(url, timeout=10) response.raise_for_status() data = response.json() converted = data["rates"][to_currency] return f"{amount} {from_currency} = {converted} {to_currency}" 
  5. Click Test connection to verify your code works

  6. Save the skill and test it with your agent

Common use cases:

  • Currency conversion: Live exchange rates for travel and e-commerce agents

  • Data validation: Normalize phone numbers, emails, or addresses before storage

  • Payment processing: Calculate fees, taxes, or discounts based on business rules

  • Inventory management: Check stock levels and apply quantity-based pricing

  • API integration: Fetch weather, stock prices, or shipping rates with built-in error handling

  • Report generation: Aggregate data and format it for presentation or export

  • Customer data transformation: Clean and standardize customer information from multiple sources


Pro tip: Combine Python Code Execution with your other skills (API, Email, Google Drive, Slack) to build robust end-to-end workflows. Your agent can fetch data via API, validate it with Python Code Execution, and send results to your team, all with production-grade reliability.