← All code samples

Download an execution debug ZIP

When an Ask or webhook run misbehaves, pull the same debug bundle operators get from Activity / watch: DAG, subscribe replay, and optional judge. Pass the execution trace_id (from Ask start, subscribe complete, or the session’s execution list).

Step What the SDK does
1. Resolve You already have trace_id, or call list_executions(session_id=…)
2. Export POST /guild/api/v1/executions/{traceId}/debug-export
3. Save Write application/zip bytes to a local path

Minimal

from stackgen import StackgenClient, StackgenConfig

client = StackgenClient(
    StackgenConfig(
        base_url="https://app.stackgen.com",
        api_token="stackgen_…",
        workspace_id="<workspace-uuid>",
    )
)

path = client.aiden.download_execution_debug_zip(
    "<trace-id>",
    "execution-debug.zip",
    # Optional: abort a hung cold export (seconds).
    # timeout_seconds=180,
)
print(path, path.stat().st_size)

Runnable CLI

#!/usr/bin/env python3
"""Download an execution debug ZIP (Activity / watch export) by trace id."""

from __future__ import annotations

import argparse
import os
import sys

from stackgen import StackgenClient, StackgenConfig


def main() -> int:
    parser = argparse.ArgumentParser(
        description="POST …/executions/{traceId}/debug-export and write the ZIP.",
    )
    parser.add_argument("--base-url", default=os.environ.get("STACKGEN_URL", ""))
    parser.add_argument("--api-token", default=os.environ.get("STACKGEN_TOKEN", ""))
    parser.add_argument(
        "--workspace-id",
        "--org-id",
        default=os.environ.get("STACKGEN_WORKSPACE_ID") or os.environ.get("STACKGEN_PROJECT") or os.environ.get("STACKGEN_ORG_ID", ""),
    )
    parser.add_argument(
        "--trace-id",
        required=True,
        help="Execution trace id (from Ask start / subscribe / Activity)",
    )
    parser.add_argument(
        "--output-path",
        default="",
        help="Local ZIP path (default: execution-<trace>-debug.zip)",
    )
    args = parser.parse_args()
    if not args.base_url or not args.api_token or not args.workspace_id:
        parser.error("set STACKGEN_URL / STACKGEN_TOKEN / STACKGEN_WORKSPACE_ID (or flags)")

    out = (args.output_path or "").strip() or f"execution-{args.trace_id[:16]}-debug.zip"
    client = StackgenClient(
        StackgenConfig(
            base_url=args.base_url,
            api_token=args.api_token,
            workspace_id=args.workspace_id,
        )
    )
    path = client.aiden.download_execution_debug_zip(args.trace_id, out)
    print(f"trace_id={args.trace_id} output={path} bytes={path.stat().st_size}")
    return 0


if __name__ == "__main__":
    raise SystemExit(main())

Related: Ask → artifact for the customer-facing session report. Live PR CI also downloads debug ZIPs for every sample that produced a session or trace and uploads them as the live-debug-zips workflow artifact.