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
{{ message }}
Repository navigation
Commit 769a790
Browse filesBrowse the repository at this point in the historyBrowse files
hzq
committed
Commit delegated runs and parent links atomically
Persist inherited execution context, the parent step and both lifecycle events before dispatch. Verify stored relationships during recovery and reconcile uncertain commit outcomes without replaying external work.
- After a child run is submitted successfully and before waiting begins, the child run ID is registered on the step record's `childRunId`. When resume replay reaches this step it looks for that child run first: if it has completed, its result is used directly (usage and steps are committed in the same checkpoint and accumulated only once); if it is still queued, executing, or awaiting approval, it keeps waiting; if it is interrupted or its outcome is unknown, a step whose level is not read-only is recorded as `uncertain` and waits for human confirmation; if it ended as failed, cancelled, or incomplete, read-only and safely retryable steps are delegated again, and "effects unknown" steps wait for human confirmation. After a human checks it as "not executed", it is delegated again on resume.
165
+
- The child record (including its depth, grants and inherited project), the parent step's `childRunId` and the `subagent.started` event commit together. A refused write cannot dispatch the child. The parent can already resolve the link at the first public notification.
166
+
- On resume, a completed child's result and usage are reused once; an active child is reattached. Unknown effects still require human confirmation. A failed or cancelled child is delegated again only when its effect allows that, or a human reconciled it as not executed.
167
+
- Reattachment checks the owner, caller, parent run and delegate step, not just a child ID. An unreadable or contradictory receipt is not treated as a missing run. A confirmed missing child may be retried automatically only for read-only work.
168
+
- If SQLite loses the commit acknowledgement, the gateway checks the freshly allocated run ID before publishing. A confirmed commit is published once. If that read also fails, the parent stops with an uncertain step for reconciliation instead of guessing that no child exists.
166
169
- When the wait is interrupted by the parent run being cancelled or the gateway closing, the child run is still cancelled as before; if the step level is not read-only it is recorded as `uncertain` (the child run may already have done something), and read-only is recorded as `failed`. When the gateway closes, the parent run therefore becomes `interrupted` / `effect_outcome_unknown`, and resuming is blocked at human confirmation; when the parent run is cancelled it still ends as `cancelled`. When a child run ends as `interrupted` or `effect_outcome_unknown` and the step level is not read-only, the parent run likewise enters the human confirmation flow.
167
170
- Delegation manages its own timeout: a timeout reports `delegate_timeout` (504), the child run is cancelled, and the timer is cleaned up at the end.
168
171
- Run slots: while the parent run waits for a child run it lends out its own run slot so the child run can enter. It is counted per parent run, lending out only one regardless of how many delegations are in parallel (0→1 lends, 1→0 takes back; when taking back and there is no free slot, it waits until there is one, and on abort or shutdown it takes back directly). Invariant: number of executing runs = number of runs holding run slots + number of parent runs that lent out run slots, and the number holding is within `[0, maxActiveRuns]` (it may briefly exceed only during abort teardown).
169
-
-When the gateway resumes queued runs at startup, a queued child run whose parent run is no longer active (not in `queued` / `in_progress` / `requires_action`) is not executed and ends as `cancelled` with the error code `parent_interrupted` (the state machine does not allow `queued` to go directly to `interrupted`).
172
+
-At startup a queued delegate needs an active parent and a matching parent step in the same owner and caller scope. For older checkpoints without a parent step ID, the gateway checks the child ID already stored on that parent's steps. An unlinked queued child is cancelled with `parent_interrupted`, not guessed from an agent name or sent to a worker.
170
173
- A child run's artifacts are not merged into the parent run; they are given as references only in the `artifacts` of the delegation result (file ID, name, sha256, and download URL).
Copy file name to clipboardExpand all lines: docs/protocol.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -788,7 +788,7 @@ Error codes and response shapes do not depend on language; only the text of `mes
788
788
|`run_not_attached`| 409 | The run shows as in progress but is not executing in this gateway process (inconsistent data, or held by another process); the cancel request was not accepted |
789
789
|`run_key_inactive`| 409 | The key that owns the run has expired, been revoked or deleted (or its account no longer exists), so the run cannot be resumed. This appears when the owner's admin key resumes another key's run; when the original key resumes by itself, expiry and revocation are already rejected at authentication with `key_expired` / `unauthorized`|
790
790
|`invalid_reconciliation`| 409 | No matching step is waiting for reconciliation |
791
-
|`effect_outcome_unknown`| 409 |The outcome of an operation with side effects is unconfirmed (the run is marked interrupted)|
791
+
|`effect_outcome_unknown`| 409 |A side effect is unconfirmed and the executing run is interrupted. If the run-creation commit itself cannot be confirmed or read back, the error includes the allocated `run_id`: inspect it before resubmitting; do not assume that no run exists.|
0 commit comments