Repository navigation
fix(orchestration): support Antigravity and non-Git conversation rollback and ACP connect indicator #21021
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(orchestration): support Antigravity and non-Git conversation rollback and ACP connect indicator #21021
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -329,7 +329,7 @@ export const layer: Layer.Layer< | |
| }).pipe(Effect.as(false)), | ||
| ), | ||
| ) | ||
| : false; | ||
| : true; | ||
| return makeCheckpoint({ | ||
| id: checkpointId, | ||
| scope: input.scope, | ||
|
|
@@ -388,7 +388,7 @@ export const layer: Layer.Layer< | |
| ordinalWithinScope: input.ordinalWithinScope, | ||
| appRunOrdinal: input.appRunOrdinal, | ||
| ref: checkpointRef, | ||
| status: "missing", | ||
| status: "ready", | ||
| files: [], | ||
| capturedAt: input.capturedAt, | ||
| }); | ||
|
|
@@ -519,6 +519,9 @@ export const layer: Layer.Layer< | |
| cause: `Checkpoint status is ${input.checkpoint.status}.`, | ||
| }); | ||
| } | ||
| if (!(yield* isGitCheckpointable(input.scope.cwd))) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟠 High When Git detection times out or fails to spawn during restore, this guard skips 🤖 Copy this AI Prompt to have your agent fix this: |
||
| return; | ||
| } | ||
|
|
||
| const restored = yield* checkpointStore.restoreCheckpoint({ | ||
| cwd: input.scope.cwd, | ||
|
|
@@ -548,9 +551,12 @@ export const layer: Layer.Layer< | |
| const deleteStaleRefs: CheckpointServiceV2Shape["deleteStaleRefs"] = (input) => | ||
| withWorkspaceLock( | ||
| input.scope.cwd, | ||
| checkpointStore.deleteCheckpointRefs({ | ||
| cwd: input.scope.cwd, | ||
| checkpointRefs: input.checkpoints.map((checkpoint) => checkpoint.ref), | ||
| Effect.gen(function* () { | ||
| if (!(yield* isGitCheckpointable(input.scope.cwd))) return; | ||
| yield* checkpointStore.deleteCheckpointRefs({ | ||
| cwd: input.scope.cwd, | ||
| checkpointRefs: input.checkpoints.map((checkpoint) => checkpoint.ref), | ||
| }); | ||
| }), | ||
| ).pipe( | ||
| Effect.mapError( | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -511,6 +511,98 @@ export const layer: Layer.Layer< | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const existingSessionProjection = projection.providerSessions.find( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (candidate) => candidate.id === providerSessionId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const isColdOrRestartingAcpConnect = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| providerThread.driver === "antigravity" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ? !(yield* Effect.try(() => providerSessions.isLive(providerSessionId)).pipe( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Effect.flatten, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Effect.orElseSucceed(() => true), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| )) || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| providerThread.nativeThreadRef === null || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| projection.runs.findLast( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (candidate) => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| candidate.ordinal < run.ordinal && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| candidate.providerThreadId === providerThread.id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| )?.status === "interrupted" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| : false; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const connectStartedAt = isColdOrRestartingAcpConnect ? yield* DateTime.now : null; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const connectTurnItem: Extract< | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| OrchestrationV2TurnItem, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { readonly type: "dynamic_tool" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| > | null = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| connectStartedAt === null | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ? null | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| : { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| id: idAllocator.derive.runSignalTurnItem({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| runId: run.id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| signal: "provider-connect", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| threadId: projection.thread.id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| runId: run.id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| nodeId: rootNode.id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| providerThreadId: providerThread.id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| providerTurnId: null, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| nativeItemRef: null, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| parentItemId: null, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ordinal: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Math.max( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ...projection.turnItems | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .filter((item) => item.runId === run.id) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| .map((item) => item.ordinal), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) + 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| status: "running", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| title: "Connecting to ACP…", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| startedAt: connectStartedAt, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| completedAt: null, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| updatedAt: connectStartedAt, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: "dynamic_tool", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| toolName: "acp_connect", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| input: {}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (connectTurnItem !== null) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| yield* eventSink.writeIfRunCurrent({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| threadId: projection.thread.id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| runId: run.id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| activeAttemptId: attempt.id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| expectedStatus: "starting", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| events: [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| id: yield* idAllocator.allocate.event({ threadId: projection.thread.id }), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: "turn-item.updated", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| threadId: projection.thread.id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| runId: run.id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| nodeId: rootNode.id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| providerInstanceId: run.providerInstanceId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| occurredAt: connectStartedAt!, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| payload: connectTurnItem, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+562
to
+581
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win 🔎 Supported by static analysis🏁 Script executed: rg -n 'starting|outbox.fail|retry|cancel|interrupt' apps/server/src/orchestration-v2/EffectWorker.ts apps/server/src/orchestration-v2/ProviderTurnStartService.ts | head -110Repository: pingdotgg/t3code Length of output: 4940 🏁 Script executed: set -eu
printf '%s\n' '--- ProviderTurnStartService start entry and failure handling ---'
nl -ba apps/server/src/orchestration-v2/ProviderTurnStartService.ts | sed -n '100,280p;480,710p;1340,1410p'
printf '%s\n' '--- EffectWorker execution, retries, and post-failure handling ---'
nl -ba apps/server/src/orchestration-v2/EffectWorker.ts | sed -n '540,790p;820,880p'
printf '%s\n' '--- Starting-state guards and recovery references ---'
rg -n -F --glob '*.ts' -e 'status === "starting"' -e 'status !== "starting"' -e 'expectedStatus: "starting"' -e 'recover' -e 'stale' apps/server/src/orchestration-v2 apps/server/src/provider || test "$?" -eq 1Repository: pingdotgg/t3code Length of output: 42479 🏁 Script executed: set -eu
printf '%s\n' '--- Recovery service files and declarations ---'
rg --files apps/server/src/orchestration-v2 | rg 'Recovery|Interrupt|Run|Orchestr'
rg -n -F --glob '*.ts' -e 'ProviderRuntimeRecoveryService' -e 'interruptAndAwaitTerminal' -e 'status === "starting"' -e 'status !== "starting"' apps/server/src/orchestration-v2/ProviderRuntimeRecoveryService.ts apps/server/src/orchestration-v2/*Interrupt*.ts apps/server/src/orchestration-v2/*Run*.ts 2>/dev/null || test "$?" -eq 1
printf '%s\n' '--- Candidate recovery declarations ---'
for f in apps/server/src/orchestration-v2/ProviderRuntimeRecoveryService.ts apps/server/src/orchestration-v2/ProviderTurnInterruptService.ts apps/server/src/orchestration-v2/RunExecutionService.ts; do
if test -f "$f"; then
echo "### $f"
rg -n -e 'export class|const make|recover|reconcile|interrupt|starting|failed|interrupted|stale' "$f" || true
fi
doneRepository: pingdotgg/t3code Length of output: 8049 🏁 Script executed: set -u
printf '%s\n' '--- ProviderRuntimeRecoveryService active-run selection and reconciliation ---'
nl -ba apps/server/src/orchestration-v2/ProviderRuntimeRecoveryService.ts | sed -n '1,230p;620,760p'
printf '%s\n' '--- Starting-status transitions in recovery and orchestration ---'
rg -n -F --glob '*.ts' -e 'status: "starting"' -e 'status: "interrupted"' -e 'status: "failed"' -e 'status === "starting"' -e 'status !== "starting"' apps/server/src/orchestration-v2/ProviderRuntimeRecoveryService.ts apps/server/src/orchestration-v2/RunFinalizationService.ts apps/server/src/orchestration-v2/Orchestrator.ts apps/server/src/orchestration-v2/RuntimeRequestService.ts || test "$?" -eq 1Repository: pingdotgg/t3code Length of output: 19926 🏁 Script executed: set -u
printf '%s\n' '--- Recovery reconciliation events and effects ---'
nl -ba apps/server/src/orchestration-v2/ProviderRuntimeRecoveryService.ts | sed -n '230,620p'
printf '%s\n' '--- Interrupt transitions for active runs ---'
nl -ba apps/server/src/orchestration-v2/Orchestrator.ts | sed -n '9180,9360p'Repository: pingdotgg/t3code Length of output: 27050 Do not let ACP connect-indicator writes block startup. If Keep interruption failures visible, but log ordinary indicator-write failures and continue startup. Suggested fix- yield* eventSink.writeIfRunCurrent({
- threadId: projection.thread.id,
- runId: run.id,
- activeAttemptId: attempt.id,
- expectedStatus: "starting",
- events: [
- {
- id: yield* idAllocator.allocate.event({ threadId: projection.thread.id }),
- type: "turn-item.updated",
- threadId: projection.thread.id,
- runId: run.id,
- nodeId: rootNode.id,
- providerInstanceId: run.providerInstanceId,
- occurredAt: connectStartedAt!,
- payload: connectTurnItem,
- },
- ],
- });
+ yield* eventSink
+ .writeIfRunCurrent({
+ threadId: projection.thread.id,
+ runId: run.id,
+ activeAttemptId: attempt.id,
+ expectedStatus: "starting",
+ events: [
+ {
+ id: yield* idAllocator.allocate.event({ threadId: projection.thread.id }),
+ type: "turn-item.updated",
+ threadId: projection.thread.id,
+ runId: run.id,
+ nodeId: rootNode.id,
+ providerInstanceId: run.providerInstanceId,
+ occurredAt: connectStartedAt!,
+ payload: connectTurnItem,
+ },
+ ],
+ })
+ .pipe(
+ Effect.catchCause((cause) =>
+ Cause.hasInterruptsOnly(cause)
+ ? Effect.failCause(cause)
+ : Effect.logWarning("failed to emit ACP connect indicator", { runId: run.id }),
+ ),
+ );📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const dismissConnectTurnItem = (completedAt: DateTime.Utc) => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| connectTurnItem === null | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ? Effect.void | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| : Effect.gen(function* () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| yield* eventSink.write({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| events: [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| id: yield* idAllocator.allocate.event({ threadId: projection.thread.id }), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: "turn-item.updated", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| threadId: projection.thread.id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| runId: run.id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| nodeId: rootNode.id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| providerInstanceId: run.providerInstanceId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| occurredAt: completedAt, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| payload: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ...connectTurnItem, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| status: "idle", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| completedAt, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| updatedAt: completedAt, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const sessionResult = yield* Effect.result( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| providerSessions.open({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| threadId: projection.thread.id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -537,11 +629,13 @@ export const layer: Layer.Layer< | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| readonly error: Error; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }) => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Effect.gen(function* () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const now = yield* DateTime.now; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| yield* dismissConnectTurnItem(now); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const nestedCause = "cause" in failed.error ? failed.error.cause : undefined; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| yield* settleRunBeforeStart({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| signal: failed.signal, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| status: "failed", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| now: yield* DateTime.now, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| now, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| providerInstanceId: run.providerInstanceId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| itemProviderThreadId: providerThread.id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| item: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
629
to
641
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win 🔎 Supported by static analysis🏁 Script executed: sed -n '575,685p' apps/server/src/orchestration-v2/ProviderTurnStartService.ts
sed -n '735,785p' apps/server/src/orchestration-v2/EffectWorker.tsRepository: pingdotgg/t3code Length of output: 6569 🏁 Script executed: set -o pipefail
printf '%s\n' '--- ProviderTurnStartService relevant declarations and callers ---'
rg -n -F --glob '*.ts' -e 'settleRunBeforeStart' -e 'settleStartFailure' -e 'ProviderTurnStartService' -e 'provider-turn.start' apps/server/src/orchestration-v2 apps/server/src/provider || test "$?" -eq 1
sed -n '430,730p' apps/server/src/orchestration-v2/ProviderTurnStartService.ts
printf '%s\n' '--- settleRunBeforeStart definition ---'
rg -n -F --glob '*.ts' -- 'const settleRunBeforeStart' apps/server/src/orchestration-v2 || test "$?" -eq 1
printf '%s\n' '--- EffectWorker invocation and interruption handling ---'
rg -n -F --glob '*.ts' -e 'providerTurnStart.start' -e 'wasCancelled' -e 'interrupt' apps/server/src/orchestration-v2/EffectWorker.ts apps/server/src/orchestration-v2
sed -n '100,190p' apps/server/src/orchestration-v2/EffectWorker.ts
printf '%s\n' '--- EventSink write contract ---'
sed -n '1,130p' apps/server/src/orchestration-v2/EventSink.tsRepository: pingdotgg/t3code Length of output: 45668 🏁 Script executed: set -o pipefail
printf '%s\n' '--- EffectWorker execute and failure handling ---'
sed -n '120,190p' apps/server/src/orchestration-v2/EffectWorker.ts
sed -n '700,790p' apps/server/src/orchestration-v2/EffectWorker.ts
printf '%s\n' '--- settleRunBeforeStart complete block ---'
sed -n '260,345p' apps/server/src/orchestration-v2/ProviderTurnStartService.ts
printf '%s\n' '--- EventSink error catch patterns ---'
rg -n -F --glob '*.ts' -e 'EventSinkWriteError' -e 'EventSinkStreamError' -e 'catchTags({' -e 'catchTag(' apps/server/src/orchestration-v2 | head -n 160Repository: pingdotgg/t3code Length of output: 14977 Keep ACP indicator failures from blocking failed-run settlement. When provider startup fails and Catch the typed Suggested fix- yield* dismissConnectTurnItem(now);
+ yield* dismissConnectTurnItem(now).pipe(
+ Effect.catchTags({
+ EventSinkWriteError: () => Effect.void,
+ EventSinkStreamError: () => Effect.void,
+ }),
+ );📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -561,7 +655,10 @@ export const layer: Layer.Layer< | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (sessionResult._tag === "Failure") { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (input.willRetry === true) return yield* sessionResult.failure; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (input.willRetry === true) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| yield* dismissConnectTurnItem(yield* DateTime.now); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return yield* sessionResult.failure; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| yield* settleStartFailure({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| signal: "provider-session-open-failure", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| title: "Provider session failed to open", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -576,7 +673,10 @@ export const layer: Layer.Layer< | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Effect.gen(function* () { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const loaded = yield* Effect.result(load); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (loaded._tag === "Success") return loaded.success; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (input.willRetry === true) return yield* loaded.failure; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (input.willRetry === true) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| yield* dismissConnectTurnItem(yield* DateTime.now); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return yield* loaded.failure; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| yield* settleStartFailure({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| signal: "provider-thread-load-failure", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| title: "Provider turn failed to start", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -705,12 +805,15 @@ export const layer: Layer.Layer< | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| toProviderInstanceId: run.providerInstanceId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| coveredRunOrdinals: { from: 1, to: Math.max(1, run.ordinal - 1) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| strategy: "full_thread_summary", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| runs: projection.runs, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| runs: projection.runs.filter((source) => source.status !== "rolled_back"), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| items: (yield* projectionStore.getTurnStartHistory(input.threadId)).filter( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (item) => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| item.runId === null || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| projection.runs.some( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (source) => source.id === item.runId && source.ordinal < run.ordinal, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (source) => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| source.id === item.runId && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| source.ordinal < run.ordinal && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| source.status !== "rolled_back", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| createdAt, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -759,6 +862,7 @@ export const layer: Layer.Layer< | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (loadedProviderThread === undefined) return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!(yield* isCurrentAttemptInStatus("starting"))) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| yield* dismissConnectTurnItem(yield* DateTime.now); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const now = yield* DateTime.now; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -831,6 +935,25 @@ export const layer: Layer.Layer< | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| startedAt: now, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const events: Array<OrchestrationV2DomainEvent> = [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ...(connectTurnItem === null | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ? [] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| : [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| id: yield* idAllocator.allocate.event({ threadId: projection.thread.id }), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: "turn-item.updated" as const, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| threadId: projection.thread.id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| runId: run.id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| nodeId: rootNode.id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| providerInstanceId: run.providerInstanceId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| occurredAt: now, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| payload: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ...connectTurnItem, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| status: "idle" as const, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| completedAt: now, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| updatedAt: now, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ]), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| id: yield* idAllocator.allocate.event({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| threadId: projection.thread.id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -917,6 +1040,7 @@ export const layer: Layer.Layer< | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| events, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if (!runningWrite.committed) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| yield* dismissConnectTurnItem(now); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const routableSubagents = projection.subagents.filter((subagent) => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -1048,8 +1172,13 @@ export const layer: Layer.Layer< | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (source) => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| source.ordinal < run.ordinal && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| source.providerThreadId === providerThread.id && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (source.status === "failed" || source.status === "interrupted") && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| !deliveredAttemptIds.has(source.activeAttemptId), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| source.status !== "rolled_back" && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (((source.status === "failed" || source.status === "interrupted") && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| !deliveredAttemptIds.has(source.activeAttemptId)) || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (runningProviderThread.nativeThreadRef?.nativeId != null && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟠 High Cancelled queued runs are replayed into the next provider prompt, so text the user removed from the queue is silently treated as conversation history. This branch selects prior runs without checking whether they started; require 🤖 Copy this AI Prompt to have your agent fix this: |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| !nativeInputRunIds.has(source.id) && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| !legacyInputRunIds.has(source.id) && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| !legacyRecoveredRunIds.has(source.id))), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const missedRunIds = new Set(missedRuns.map((source) => source.id)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const missedItems = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟠 High
orchestration-v2/CheckpointService.ts:391A checkpoint captured in a non-Git folder is marked
readyeven though itscheckpointRefwas never created; if Git is initialized later,restoretreats it as a Git checkpoint and fails on that missing ref, leaving rollback incomplete after the provider has already been rolled back. Persist whether the checkpoint is conversation-only and use that flag during restore instead of relying on the workspace's current Git status.🤖 Copy this AI Prompt to have your agent fix this: