You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `batch` section describes the batch file schema and dependent workflow capabilities. Agents can query it directly:
85
+
86
+
```bash
87
+
# Discover batch operation fields
88
+
aperture api my-api --describe-json --jq '.batch.operation_schema'
89
+
90
+
# Discover dependent workflow semantics
91
+
aperture api my-api --describe-json --jq '.batch.dependent_workflows'
92
+
```
93
+
75
94
**Command mapping fields in the manifest:**
76
95
77
96
| Field | Type | Description |
@@ -246,6 +265,159 @@ aperture api my-api --batch-file operations.json --json-errors
246
265
}
247
266
```
248
267
268
+
### Dependent Batch Workflows
269
+
270
+
When operations depend on each other's results, Aperture supports **variable capture and interpolation** within batch files. This enables multi-step workflows like "Create User → capture ID → Get User by ID → Add to Group" in a single batch invocation.
271
+
272
+
Aperture automatically detects when a batch uses dependency features and switches from concurrent to sequential execution. Existing batch files without dependency features continue to run concurrently with no changes required.
273
+
274
+
#### Batch File Format
275
+
276
+
Three optional fields on each operation enable dependent workflows:
277
+
278
+
| Field | Type | Description |
279
+
|-------|------|-------------|
280
+
|`capture`|`map<string, string>`| Extract scalar values from the response via JQ queries. Maps variable name → JQ query. |
281
+
|`capture_append`|`map<string, string>`| Append extracted values to a named list via JQ queries. Enables fan-out/aggregate patterns. |
282
+
|`depends_on`|`string[]`| Explicit dependency on other operations by `id`. |
283
+
284
+
Operations that use `capture`, `capture_append`, or `depends_on`**must** have an `id`.
Both `beat-1` and `beat-2` append their extracted IDs to the `event_ids` list. `set-order` waits for both, then `{{event_ids}}` interpolates as a JSON array literal: `["id-1","id-2"]`.
324
+
325
+
#### Variable Interpolation
326
+
327
+
Captured values are interpolated into operation `args` using `{{variable}}` syntax:
328
+
329
+
- **Scalar variables** (from `capture`): `{{name}}` is replaced with the captured string value.
330
+
- **List variables** (from `capture_append`): `{{name}}` is replaced with a JSON array literal (e.g., `["a","b","c"]`).
331
+
332
+
If a scalar and a list share the same name, the scalar takes precedence.
333
+
334
+
#### Implicit Dependencies
335
+
336
+
Operations that reference `{{variable}}` in their args automatically depend on the operation that captures that variable, even without an explicit `depends_on`. This means the following two batch files are equivalent:
For `capture_append` variables with multiple providers, the consumer implicitly depends on **all** providers.
362
+
363
+
#### Execution Strategy
364
+
365
+
Aperture automatically selects the execution path based on the batch content:
366
+
367
+
| Condition | Execution Path | Behavior |
368
+
|-----------|---------------|----------|
369
+
| No operation uses `capture`, `capture_append`, or `depends_on` | **Concurrent** (original) | Parallel execution with concurrency/rate-limit controls |
370
+
| Any operation uses `capture`, `capture_append`, or `depends_on` | **Dependent** (new) | Sequential in topological order with variable interpolation |
2. Topologically sorts operations (Kahn's algorithm). Operations without dependencies preserve their original relative order.
375
+
3. Executes operations one at a time in sorted order.
376
+
4. Before each operation: interpolates `{{variables}}` in args.
377
+
5. After each operation: extracts captures into the variable store.
378
+
379
+
#### Atomic Execution
380
+
381
+
In dependent mode, execution halts immediately on the first failure. Subsequent operations are marked as **"Skipped due to prior failure"** and no further HTTP requests are made. This prevents cascading errors and ensures the agent receives a clear signal about which step failed.
| Missing ID | Operation uses `capture`/`depends_on` but has no `id` | `capture` without `id` |
399
+
| Undefined variable | `{{var}}` references a variable not captured by any operation | `{{typo}}` |
400
+
| Capture failed | JQ query returned null/empty or failed | `.missing_field` on `{"id": 1}` |
401
+
402
+
```bash
403
+
aperture api my-api --json-errors --batch-file cycle.yaml
404
+
```
405
+
406
+
```json
407
+
{
408
+
"error_type": "Validation",
409
+
"message": "Dependency cycle detected in batch operations: a → b",
410
+
"context": "Remove circular dependencies between batch operations.",
411
+
"details": {
412
+
"cycle": ["a", "b"]
413
+
}
414
+
}
415
+
```
416
+
417
+
#### Dry-Run Behavior
418
+
419
+
In `--dry-run` mode, the dependent execution path runs but receives dry-run output (request details) instead of real API responses. JQ capture queries will typically fail because the dry-run output does not match the expected response schema. The first operation is marked as a capture failure, and subsequent operations are skipped. This is expected behavior — dry-run validates request construction, not response processing.
420
+
249
421
## Automatic Retry with Exponential Backoff
250
422
251
423
Aperture supports automatic retries for transient failures, with exponential backoff and jitter. This is essential for reliable agent workflows interacting with rate-limited or occasionally unavailable APIs.
0 commit comments