Skip to main content
Datazone Agents

Overview

Actions allow you to deploy serverless Python functions that can be triggered on-demand by endpoints or used as tools by AI agents. Think of actions as lambda-like functions that run in isolated environments.
  • Project Structure
my-project
config.yml
actions
send_mail_action.py

What Are Actions?

Actions are custom Python functions that run in isolated environments, accept parameters, return structured results, and can be triggered via endpoints or used as agent tools.

Use Cases

  • Send notifications
  • Process data
  • Call external APIs
  • Generate reports
  • Automate workflows
  • Extend AI agent capabilities with custom logic

Action with Logging

Use context to log information during execution:

Action with Optional Parameters

Actions SDK Reference

Decorator

The @action decorator marks a function as executable by Datazone.

Context API

The context object provides logging capabilities during action execution:
function
Log informational messages during action execution.
function
Log warning messages for potential issues.
function
Log error messages when operations fail.
All logs are collected and returned with the action response.

Variable API

The Variable class allows actions to access secure variables stored in Datazone:
class
Access workspace variables securely within actions.
Variables are workspace-scoped and can be marked as secret to encrypt sensitive data like API keys, passwords, and tokens. Learn more in the Variables documentation.

Example: Using Variables

Security Best Practice: Always store sensitive credentials as Variables rather than hardcoding them in your action code.

execute_query

The execute_query function runs SQL queries against your Datazone datasets and returns structured results:
function
Execute a SQL query against Datazone datasets.
Returns a QueryResult object with:
  • data — list of row dictionaries
  • status — execution status string

Example: Query and Transform

KnowledgeObject

The KnowledgeObject client reads and writes Knowledge Object instances from within an action. Instances are addressed by their opaque _key, and operations run on the action’s project (main branch by default).
class
Access instances of a knowledge object by name.
Methods:
  • get(key, add_relationships=False) — fetch one instance (a dict) by its _key.
  • list(filters=None, page=1, page_size=50, fields=None) — iterate pages of instances (see below).
  • update(key, payload) — partially update an instance; returns the updated instance.
  • delete(key) — delete an instance by its _key.
  • batch_upsert(payloads) — insert/update up to 1000 instances in one call; returns {"created", "updated", "total"}.
Filtering and pagination. list(...) returns an iterator of pages; each page exposes .items and .total_count. filters is a list of {"column", "operator", "value"} objects combined with AND (operators: equal, not_equal, contains, not_contains, greater_than, less_than).

Example: Read and upsert

See the Actions SDK page under Knowledge Objects for the full method reference.

FileContainerClient

FileContainerClient provides access to files stored in the Datazone file container (LakeFS/S3-compatible storage). It is automatically initialized as file_client in agent code execution environments — no import is required.
file_client is pre-initialized in agent code execution contexts. It is not available inside @action decorated functions.
method
Fetch raw bytes for a file from the file container.
  • path — path relative to the file container root
  • Returns raw bytes
  • Raises ValueError if the file exceeds 10 MB or cannot be fetched

Examples: Reading Different File Types

CloudFeedClient

CloudFeedClient is a simplified SAP connector for reading tables and executing function modules from within actions:
class
SAP CloudFeed client for table access and function execution.Constructor parameters:
  • base_url — base URL of the SAP system
  • username — SAP username
  • password — SAP password
  • timeout (optional) — request timeout in seconds (default: 30)
  • max_retries (optional) — max retries on failure (default: 10)
  • backoff_factor (optional) — exponential backoff factor (default: 0.3)

Example: Query SAP Sales Orders

Example: Execute SAP Function Module

Example: Search and Inspect SAP Tables

Configuration

Add to config.yaml

Register your actions in config.yaml:

Repository Structure

config.yml
actions
send_email.py
process_data.py
generate_report.py
Each file should contain one @action decorated function. Action function names must be unique within your project.

Return Values

Actions should return structured data (dict, list, or primitives):

Error Handling

Actions can raise exceptions - they’ll be captured and returned:

Using Actions

1. In Endpoints

Connect actions to API endpoints for webhook-style triggers:
When the endpoint is called, the action executes automatically. Learn more in the Endpoints documentation.

2. In Agents

Enable actions as tools for AI agents: When creating an agent:
  1. Select “Action” in the tools section
  2. Choose which actions the agent can use
  3. The agent will automatically call actions when needed
The AI agent decides when and how to use actions based on user questions. Learn more in the Agents documentation.

Examples

Slack Notification

Data Validation

API Integration

Next Steps