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.
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 plainfrom glaip_sdk import Client
client = Client()
agent = client.agents.get_agent_by_id("analytics-agent")
# Rich text (default renderer)
print(agent.run("Provide a concise summary"))
# Plain output for scripting
print(client.agents.run_agent(agent.id, "List KPIs", renderer="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 guide 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
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.
Related Documentation
Install & Configure — bootstrap environments for automation servers.
Agents guide — full lifecycle and runtime overrides.
Configuration management — promote resources between environments.
CLI commands reference — explore automation flags in detail.
Last updated