Automation and Scripting

Automate AIP workflows from Python scripts, shell pipelines, or CI jobs. Use this guide when you need repeatable patterns for consistent output formats, resource promotion, and scheduling hooks that teammates can reuse across environments.

circle-info

For a full capability breakdown, refer to the AIP matrixarrow-up-right. Automation today leans on REST for schedules and certain runtime overrides—plan scripts accordingly until CLI wrappers land.

circle-info

CLI automations can target resources by ID or unique name. When scripting loops, prefer IDs or add --select handling so partial name matches do not prompt for input mid-run.

circle-info

The CLI-focused sections double as a no-code playbook for data developers. Python snippets are optional and aimed at engineering teams extending these patterns in code.

Choose the Right Output Format

When to use: Tailor CLI output for downstream systems, docs, or logs before integrating into scripts.

# JSON for automation
aip agents get analytics-agent --view json > agent.json

# Markdown for docs
aip agents run analytics-agent --input "Create summary" --view md > REPORT.md

# Plain text for logs
aip agents run analytics-agent --input "Quick check" --view plain

Script Resource Promotion

When to use: Promote agents and tools between sandboxes, staging, and production with audit trails.

Use the export/import workflows from the Configuration management guidearrow-up-right as the source of truth. When you automate them, wrap the commands so your CI job can back up or promote resources in one run:

The script centralises resource selection for CI but defers ordering, validation, and import strategy to the configuration guide’s checklist.

Automate Prompt Iteration

When to use: Batch-run prompts for evaluation, regression testing, or manual review.

Extend the configuration guide’s rapid-iteration loop with automation steps that enforce reproducibility. Example nightly job:

This focuses on the scripting concerns—file paths, idempotent edits, and artifact capture—while the linked configuration guide covers the manual review and promotion steps.

Run Agents in CI

When to use: Block deployments until sanity checks pass or surface usage metrics in pipelines.

Store credentials in your CI secret manager and inject them as environment variables before executing.

Python Automation Pattern

When to use: Embed agent calls inside existing Python services, notebooks, or ETL jobs.

The renderer="silent" option suppresses streaming UI output so your script can capture the final text response directly.

Schedule Runs

When to use: Pair with cron, Cloud Scheduler, or third-party orchestrators until native scheduling arrives in the SDK/CLI.

Scheduling is currently exposed via REST only. Monitor schedules with GET /schedules or your automation telemetry until SDK/CLI wrappers land.

Common automation failures

Symptom
Likely cause
Fix

Cron job exits with command not found

aip not on the scheduler PATH.

Prefix with the full path or source the profile before invoking the CLI.

CI run fails with 401 Unauthorized

Expired or missing API key in the runner environment.

Rotate credentials and inject them via secrets or environment variables per job.

Scripts hang on interactive prompts

CLI fuzzy search triggered by partial names.

Pass IDs, use --select handling, or add --simple to list commands in automation.

SDK automation times out intermittently

Backend slow or default timeout too low.

Increase Client(timeout=...) or add retry logic with exponential backoff.

Automation Tips

When to use: Sense-check your automation plan before scaling or handing it off to new team members.

1

Use JSON everywhere

It is the most resilient format for piping into tests or dashboards.

2

Keep exports in Git

Treat agent/tool JSON like infrastructure-as-code and review changes via pull requests.

3

Log run IDs

Responses include X-Run-ID; store it to trace streaming output later.

4

Fail fast in CI

Run set -euo pipefail (Bash) or equivalent constructs to surface agent errors quickly.

Last updated