Ask → wait for execution
Start Ask Guild with a pinned workflow, then poll until execution.status settles.
No artifact download — use this when you only need trace/session ids or execution outcome.
Ask journeys use the API token only (no webhook token). Pin a workflow with
entity_refs in CI so routing is deterministic.
| Step | What the SDK does |
|---|---|
| 1. Start | POST /guild/api/v1/guild/ask/start with message and optional entity_refs |
| 2. Poll | GET /guild/api/v1/executions/{traceId} until status is terminal and trace_settled |
Minimal — start and poll
from stackgen import StackgenClient, StackgenConfig
client = StackgenClient(
StackgenConfig(
base_url="https://app.stackgen.com",
api_token="stackgen_…",
org_id="<project-uuid>",
)
)
start = client.aiden.start_ask(
"Run triage for checkout CPU alert",
entity_refs=[{"name": "incident-triage", "type": "workflow"}],
)
trace = client.aiden.wait_for_execution(start["trace_id"])
print(trace["session_id"], trace["execution"]["status"])import { StackgenClient, StackgenConfig } from "stackgen-sdk";
const client = new StackgenClient(
new StackgenConfig({
baseUrl: "https://app.stackgen.com",
apiToken: "stackgen_…",
orgId: "<project-uuid>",
}),
);
const start = await client.aiden.startAsk("Run triage for checkout CPU alert", {
entityRefs: [{ name: "incident-triage", type: "workflow" }],
});
const trace = await client.aiden.waitForExecution(String(start.trace_id));
const execution = trace.execution as Record<string, unknown>;
console.log(trace.session_id, execution.status);Runnable CLI
#!/usr/bin/env python3
"""Ask Guild start → wait for execution (no artifact download).
Documented at https://appcd-dev.github.io/stackgen-sdk/code-samples/ask-execution/
Usage:
python ask-wait-session.py \\
--base-url https://app.stackgen.com \\
--api-token stackgen_… \\
--org-id <project-uuid> \\
--message 'Run triage for checkout CPU alert' \\
--workflow incident-triage
"""
from __future__ import annotations
import argparse
import json
import sys
from stackgen import StackgenClient, StackgenConfig
from stackgen.errors import StackgenError
def main() -> int:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--base-url", required=True)
parser.add_argument("--api-token", required=True)
parser.add_argument("--org-id", required=True)
parser.add_argument("--message", required=True)
parser.add_argument(
"--workflow",
required=True,
help="Workflow name for entity_refs pin",
)
parser.add_argument("--timeout-seconds", type=int, default=1800)
parser.add_argument("--poll-interval-seconds", type=int, default=5)
args = parser.parse_args()
client = StackgenClient(
StackgenConfig(
base_url=args.base_url,
api_token=args.api_token,
org_id=args.org_id,
timeout_seconds=args.timeout_seconds,
poll_interval_seconds=args.poll_interval_seconds,
)
)
start = client.aiden.start_ask(
args.message,
entity_refs=[{"name": args.workflow, "type": "workflow"}],
)
trace_id = start.get("trace_id")
session_id = start.get("session_id")
print("start:", json.dumps(start, indent=2))
trace = client.aiden.wait_for_execution(str(trace_id))
execution = trace.get("execution") or {}
session_id = session_id or trace.get("session_id")
print(
f"settled status={execution.get('status')} "
f"trace_settled={execution.get('trace_settled')} "
f"session_id={session_id}",
file=sys.stderr,
)
return 0
if __name__ == "__main__":
try:
raise SystemExit(main())
except StackgenError as exc:
print(f"error: {exc}", file=sys.stderr)
raise SystemExit(1)/**
* Ask Guild start → wait for execution (no artifact download).
*
* Docs: https://appcd-dev.github.io/stackgen-sdk/code-samples/ask-execution/
*
* Usage:
* npx tsx ask-wait-session.ts \
* --base-url https://app.stackgen.com \
* --api-token stackgen_… \
* --org-id <project-uuid> \
* --message 'Run triage for checkout CPU alert' \
* --workflow incident-triage
*/
import { parseArgs } from "node:util";
import { StackgenClient, StackgenConfig, StackgenError } from "stackgen-sdk";
async function main(): Promise<void> {
const { values } = parseArgs({
options: {
"base-url": { type: "string" },
"api-token": { type: "string" },
"org-id": { type: "string" },
message: { type: "string" },
workflow: { type: "string" },
"timeout-seconds": { type: "string", default: "1800" },
"poll-interval-seconds": { type: "string", default: "5" },
},
});
if (!values["base-url"] || !values["api-token"] || !values["org-id"] || !values.message || !values.workflow) {
throw new Error("require --base-url, --api-token, --org-id, --message, --workflow");
}
const client = new StackgenClient(
new StackgenConfig({
baseUrl: values["base-url"],
apiToken: values["api-token"],
orgId: values["org-id"],
timeoutSeconds: Number(values["timeout-seconds"]),
pollIntervalSeconds: Number(values["poll-interval-seconds"]),
}),
);
const start = await client.aiden.startAsk(values.message, {
entityRefs: [{ name: values.workflow, type: "workflow" }],
});
console.log("start:", JSON.stringify(start, null, 2));
const traceId = String(start.trace_id ?? "");
let sessionId = String(start.session_id ?? "");
const trace = await client.aiden.waitForExecution(traceId);
const execution = (trace.execution ?? {}) as Record<string, unknown>;
if (!sessionId) {
sessionId = String(trace.session_id ?? "");
}
console.error(
`settled status=${execution.status} trace_settled=${execution.trace_settled} sessionId=${sessionId}`,
);
}
main().catch((err) => {
console.error(err instanceof StackgenError ? err.message : err);
process.exit(1);
});Related: Ask → artifact — same start flow plus artifact download.