fix(orchestrator): keep stop and steer responsive #3865
ClosedPixPMusic(GitHub profile, opens in a new tab)wants to merge 6 commits into
t3code/codex-turn-mapping fromrefs/pull/3865/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts line 3801Resolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -3700,0 +3722,21 @@3722+ updated.delete(activeTurn.nativeTurnId);3723+ } else {3724+ updated.set(activeTurn.nativeTurnId, waiters);3725+ }3726+ return updated;3727+ });3728+ const stopped = yield* client3729+ .request("turn/interrupt", {3730+ threadId,3731+ turnId: activeTurn.nativeTurnId,3732+ })3733+ .pipe(3734+ Effect.andThen(Deferred.await(terminal)),3735+ Effect.timeoutOption("10 seconds"),3736+ Effect.ensuring(unregisterTerminalWaiter),3737+ );3738+ if (Option.isNone(stopped)) {3739+ return yield* toProtocolError(3740+ `Provider turn ${turnInput.providerTurnId} did not reach a terminal state before the interrupt timeout.`,3741+ );3742+ }apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts line 3708OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -3694,6 +3702,7 @@36943702 `Provider turn ${turnInput.providerTurnId} is not active and cannot be interrupted.`,36953703 );36963704 }3697- yield* client.request("turn/interrupt", {3698- threadId,3699- turnId: activeTurn.nativeTurnId,3705+ const terminal = yield* Deferred.make<void>();3706+ yield* Ref.update(turnWaiters, (current) => {3707+ const updated = new Map(current);3708+ const waiters = new Set(updated.get(activeTurn.nativeTurnId));
- packages/client-runtime/src/state/threadCommands.ts line 141OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -123,4 +138,4 @@123138 label: "environment-data:commands:thread:interrupt-turn",124139 execute: (input: InterruptThreadTurnInput) => interruptThreadTurn(input),125140 scheduler,126- concurrency,141+ concurrency: controlConcurrency,
- packages/client-runtime/src/state/threadCommands.ts line 161OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -62,0 +141,21 @@141+ const settle = () => {142+ active.delete(result);143+ if (active.size === 0 && threads.get(key) === active) {144+ threads.delete(key);145+ }146+ };147+ void result.then(settle, settle);148+ return result;149+ },150+ },151+ interruptTurn: {152+ label: commands.interruptTurn.label,153+ run: async (registry, input) => {154+ const startsAtDispatch = Array.from(155+ pendingStarts.get(registry)?.get(pendingKey(input)) ?? [],156+ );157+ const result = await commands.interruptTurn.run(registry, input);158+ if (startsAtDispatch.length === 0 || !isThreadTurnNotInterruptibleFailure(result)) {159+ return result;160+ }161+ await Promise.allSettled(startsAtDispatch);
- packages/client-runtime/src/state/threadCommands.ts line 153Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -62,0 +133,21 @@133+ if (inFlight === undefined) {134+ inFlight = new Set();135+ byThread.set(key, inFlight);136+ }137+ const active = inFlight;138+ const threads = byThread;139+ const result = commands.startTurn.run(registry, input);140+ active.add(result);141+ const settle = () => {142+ active.delete(result);143+ if (active.size === 0 && threads.get(key) === active) {144+ threads.delete(key);145+ }146+ };147+ void result.then(settle, settle);148+ return result;149+ },150+ },151+ interruptTurn: {152+ label: commands.interruptTurn.label,153+ run: async (registry, input) => {
juliusmarminge closed this
Sign in to join this conversation.


Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID:
9f216029-5ab6-451c-85d3-41c2d473e4e0You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share