Implementation:A5c ai Babysitter ctx task breakpoint parallel
Appearance
| Knowledge Sources | |
|---|---|
| Domains | Agent_Orchestration, Runtime_Execution |
| Last Updated | 2026-10-23 00:00 GMT |
Overview
Concrete runtime intrinsics for executing tasks, breakpoints, and parallel operations provided by the Babysitter SDK.
Description
The ctx object exposes three core intrinsics during orchestration execution:
- ctx.task(task, args, options?) — Invokes a defined task, resolving via the event-sourced journal. Each invocation produces an effect that is either replayed (deterministic) or dispatched as a new effect.
- ctx.breakpoint(payload, options?) — Pauses execution for human approval. Auto-approves in non-interactive mode. Disambiguates repeated breakpoints with per-call counters.
- ctx.parallel.all(thunks, options?) — Runs an array of lazy thunks, collecting all pending effects into a single batch. Supports bounded concurrency via maxConcurrency.
These intrinsics are the execution bridge between task definitions and the journal-backed runtime.
Usage
- Sequential task execution: Use ctx.task to invoke registered tasks in order.
- Human approval gates: Use ctx.breakpoint to pause for plan review, iteration review, or final approval.
- Parallel quality checks: Use ctx.parallel.all to run multiple checks concurrently, collecting results when all complete.
Code Reference
Source Location
- Repository: Babysitter
- File (ctx.task): packages/babysitter-sdk/src/runtime/intrinsics/task.ts:L68-95
- File (ctx.breakpoint): packages/babysitter-sdk/src/runtime/intrinsics/breakpoint.ts:L44-120
- File (ctx.parallel): packages/babysitter-sdk/src/runtime/intrinsics/parallel.ts:L10-69
- File (context wiring): packages/babysitter-sdk/src/runtime/processContext.ts:L100-112
Signature
// ctx.task
ctx.task<TArgs, TResult>(
task: DefinedTask<TArgs, TResult>,
args: TArgs,
options?: TaskInvokeOptions
): Promise<TResult>
// ctx.breakpoint
ctx.breakpoint<T>(
payload: T,
options?: TaskInvokeOptions & BreakpointRoutingOptions
): Promise<BreakpointResult>
// BreakpointResult: { approved: boolean, response?: string }
// BreakpointRoutingOptions: { label?, breakpointId?, expert?, tags?, strategy?, autoApproveAfterN? }
// ctx.parallel.all
ctx.parallel.all<T>(
thunks: Array<() => T | Promise<T>>,
options?: ParallelAllOptions
): Promise<T[]>
// ParallelAllOptions: { maxConcurrency?: number, executionStrategy?: 'sequential' | 'concurrent' | 'adaptive' }
// ctx.parallel.map
ctx.parallel.map<TItem, TOut>(
items: TItem[],
fn: (item: TItem) => TOut | Promise<TOut>,
options?: ParallelAllOptions
): Promise<TOut[]>
Import
// Accessible via the ctx object passed to the process function
// No direct import needed — ctx is provided by the runtime
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| ctx.task: task | DefinedTask | Yes | A task created via defineTask |
| ctx.task: args | TArgs | Yes | Arguments to pass to the task builder |
| ctx.breakpoint: payload | T | Yes | Breakpoint context (question, title, files) |
| ctx.parallel.all: thunks | Array<() => T> | Yes | Lazy thunk array |
| ctx.parallel.all: options.maxConcurrency | number | No | Concurrency limit (>=1) |
Outputs
| Name | Type | Description |
|---|---|---|
| ctx.task returns | Promise<TResult> | Effect-resolved task result |
| ctx.breakpoint returns | Promise<BreakpointResult> | { approved, response? } |
| ctx.parallel.all returns | Promise<T[]> | Array of results in input order |
Usage Examples
Sequential Task Execution
import { defineTask, createRun } from "@a5c-ai/babysitter-sdk";
const planTask = defineTask("plan", (args) => ({ kind: "agent", title: "Plan", agent: { ... } }));
const implTask = defineTask("implement", (args) => ({ kind: "agent", title: "Implement", agent: { ... } }));
const process = async (input, ctx) => {
const plan = await ctx.task(planTask, { feature: input.feature });
const impl = await ctx.task(implTask, { feature: input.feature, plan });
return impl;
};
Breakpoint for Human Approval
const process = async (input, ctx) => {
const plan = await ctx.task(planTask, input);
// Pause for human review of the plan
const review = await ctx.breakpoint({
question: "Approve this plan?",
title: "Plan Review",
context: { runId: ctx.runId, files: [{ path: "artifacts/plan.md", format: "markdown" }] },
});
if (!review.approved) {
throw new Error("Plan not approved");
}
// Continue with implementation
return ctx.task(implTask, { ...input, plan });
};
Parallel Quality Checks
const process = async (input, ctx) => {
const impl = await ctx.task(implTask, input);
// Run quality checks in parallel
const [coverage, lint, typeCheck, security] = await ctx.parallel.all([
() => ctx.task(coverageCheckTask, { files: impl.filesCreated }),
() => ctx.task(lintCheckTask, { files: impl.filesCreated }),
() => ctx.task(typeCheckTask, { files: impl.filesCreated }),
() => ctx.task(securityCheckTask, { files: impl.filesCreated }),
], { maxConcurrency: 4 });
return { coverage, lint, typeCheck, security };
};
Related Pages
Implements Principle
- Principle:A5c_ai_Babysitter_Orchestration_Execution
- Principle:A5c_ai_Babysitter_TDD_Quality_Convergence_Methodology
Requires Environment
Uses Heuristics
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment