Skip to main content
Add custom Python logic to your agent with pre-installed libraries. The Python Code Block lets you process data, integrate with external services, perform calculations, and implement custom business logic within your agent’s workflow.

Adding a Python Code Block

Navigate to your agent’s workflow editor
  • Drag the Python Code Block from the components panel
  • Connect it to your desired step in the workflow
  • Use the code editor to implement your custom logic
Available Variables:
  • input (str): Input from previous steps.
  • client_data (dict): Contains user context with the following keys:
    • user_id (str): The user’s unique identifier.
    • conversation_id (str): The conversation’s unique identifier.
    • user_input (str): The user’s input text.
    • user_roles (List[str]): The user’s roles.
    • user_groups (List[str]): The user’s groups.
    • images (List[str]): An array of image URLs.
    • additional_info (List[Any]): an array of objects containing additional information passed to the agent.
    • step_inputs (List[Any]): The inputs for the current step.
    • files (List[str]): The files associated with the request.
  • execution_parameters (dict): Contains the following keys:
    • execution_id (str): The unique identifier for the execution.
    • step_results_by_type (dict): A dictionary containing the results of the previous steps, ordered by completion, with the following keys:
      • model (List[Any]): The results of the model steps.
      • data_source (List[Any]): The results of the data search steps.
      • memory_load (List[Any]): The results of the memory load steps.
      • memory_store (List[Any]): The results of the memory store steps.
      • python (List[Any]): The results of the python steps.
      • router (List[Any]): The results of the router steps.
      • tool_action (List[Any]): The results of the tool action steps.
      • agent (List[Any]): The results of the agent steps.
airia==0.1.25aiohappyeyeballs==2.6.1aiohttp==3.12.14aiosignal==1.4.0annotated-types==0.7.0anyio==4.9.0asgiref==3.8.1asn1crypto==1.5.1atpublic==5.1attrs==25.3.0azure-ai-vision-imageanalysis==1.0.0azure-core==1.35.0azure-cli==2.80.0azure-identity==1.25.1azure-storage-blob==12.25.1azure-keyvault==4.2.0beautifulsoup4==4.13.4boto3==1.38.4botocore==1.38.4Brotli==1.2.0cachetools==6.2.0certifi==2025.4.26cffi==1.17.1charset-normalizer==3.4.1click==8.1.8cloudpickle==3.0.0cmdstanpy==1.2.5contourpy==1.3.2cryptography==45.0.5cycler==0.12.1Cython==3.0.12dataclasses-json==0.6.7decorator==5.2.1defusedxml==0.7.1Deprecated==1.2.18distro==1.9.0dnspython==2.7.0email_validator==2.2.0et_xmlfile==2.0.0fastapi==0.120.1fastapi-cli==0.0.7filelock==3.18.0filetype==1.2.0fonttools==4.57.0frozendict==2.4.6frozenlist==1.6.0gevent==25.4.2geventhttpclient==2.3.3googleapis-common-protos==1.70.0greenlet==3.2.1grpcio==1.71.0gurobipy==12.0.2h11==0.16.0holidays==0.71html5lib==1.1httpcore==1.0.9httptools==0.6.4httpx==0.28.1idna==3.10imageio==2.37.0imageio-ffmpeg==0.6.0importlib_metadata==8.6.1importlib_resources==6.5.2iniconfig==2.1.0isodate==0.7.2Jinja2==3.1.6jiter==0.11.1jmespath==1.0.1joblib==1.4.2json_repair==0.43.0jsonpatch==1.33jsonpointer==3.0.0kiwisolver==1.4.8langchain-core==1.0.3langchain-openai==1.0.2langchain-text-splitters==1.0.0langsmith==0.4.41lxml==5.4.0markdown-it-py==3.0.0MarkupSafe==3.0.2marshmallow==3.23.0matplotlib==3.10.1mdurl==0.1.2moviepy==2.2.1multidict==6.4.3multitasking==0.0.11mypy_extensions==1.1.0nltk==3.9.1numpy==1.26.4docxtpl==0.20.0openai==2.7.1opencv-python==4.11.0.86opencv-python-headless==4.11.0.86openpyxl==3.1.5opentelemetry-api==1.32.1opentelemetry-exporter-otlp==1.32.1opentelemetry-exporter-otlp-proto-common==1.32.1opentelemetry-exporter-otlp-proto-grpc==1.32.1opentelemetry-exporter-otlp-proto-http==1.32.1opentelemetry-instrumentation==0.53b1opentelemetry-instrumentation-asgi==0.53b1opentelemetry-instrumentation-fastapi==0.53b1opentelemetry-proto==1.32.1opentelemetry-sdk==1.32.1opentelemetry-semantic-conventions==0.53b1opentelemetry-util-http==0.53b1orjson==3.11.1packaging==24.2pandas==2.2.3pdf2image==1.17.0peewee==3.18.2pgeocode==0.5.0pillow==11.3.0pillow-avif-plugin==1.5.2pip-upgrade==0.0.6platformdirs==4.3.7playwright==1.54.0pluggy==1.5.0proglog==0.1.11prometheus_client==0.21.1propcache==0.3.1prophet==1.1.6protobuf==5.29.5psycopg2-binary==2.9.10pybase64==1.4.2pycparser==2.22pydantic==2.11.3pydantic-settings==2.9.1pydantic_core==2.33.1pyee==13.0.0Pygments==2.19.1PyJWT==2.10.1PyMuPDF==1.25.5PyMySQL==1.1.1pyodbc==5.2.0pyOpenSSL==25.1.0pyparsing==3.2.3pytesseract==0.3.13pytest==8.3.5pytest-asyncio==0.26.0python-dateutil==2.9.0.post0python-docx==1.1.2python-docx-replace==0.4.4python-dotenv==1.1.0python-multipart==0.0.20python-pptx==1.0.2python-rapidjson==1.20pytz==2025.2PyYAML==6.0.2regex==2024.11.6requests==2.32.4requests-toolbelt==1.0.0rich==14.0.0rich-toolkit==0.14.3s3transfer==0.12.0scipy==1.15.2shellingham==1.5.4simple-salesforce==1.12.6slack-sdk==3.35.0six==1.17.0sniffio==1.3.1snowflake-connector-python==3.14.1snowflake-snowpark-python==1.31.0snowflake.core==1.4.0sortedcontainers==2.4.0soupsieve==2.7SQLAlchemy==2.0.40stanio==0.5.1starlette==0.49.1tenacity==9.1.2tomlkit==0.13.2tqdm==4.67.1tritonclient==2.56.0typer==0.15.2typing-inspect==0.9.0typing-inspection==0.4.0typing_extensions==4.13.2tzdata==2025.2tzlocal==5.3.1ujson==5.10.0urllib3==2.5.0uvicorn==0.34.2uvloop==0.21.0watchfiles==1.0.5weaviate-client==4.16.9webencodings==0.5.1websockets==15.0.1wrapt==1.17.2XlsxWriter==3.2.3yarl==1.20.0yfinance==0.2.57youtube-transcript-api==1.0.3zipp==3.21.0zope.event==5.0zope.interface==7.2zstandard==0.23.0