Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/loop/claude-sdk-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
spawn,
spawnSync,
} from "bun";
import { DEFAULT_CLAUDE_MODEL } from "./constants";
import { AGENT_TURN_TIMEOUT_MS, DEFAULT_CLAUDE_MODEL } from "./constants";
import { findFreePort } from "./ports";
import { DETACH_CHILD_PROCESS, killChildProcess } from "./process";
import type { Options, RunResult } from "./types";
Expand Down Expand Up @@ -65,10 +65,9 @@ const BACKGROUND_TASK_CONTINUATION =
"Background tasks are complete. Continue with the task.";
const DEFAULT_CHILD_POLL_INTERVAL_MS = 2000;
const START_TIMEOUT_MS = 60_000;
const DEFAULT_WAIT_TIMEOUT_MS = 600_000;

let childPollIntervalMs = DEFAULT_CHILD_POLL_INTERVAL_MS;
let waitTimeoutMs = DEFAULT_WAIT_TIMEOUT_MS;
let waitTimeoutMs = AGENT_TURN_TIMEOUT_MS;

type CountChildProcessesFn = (pid: number) => number;

Expand Down Expand Up @@ -193,7 +192,7 @@ export const claudeSdkInternals = {
childPollIntervalMs = next;
},
restoreWaitTimeoutMs(): void {
waitTimeoutMs = DEFAULT_WAIT_TIMEOUT_MS;
waitTimeoutMs = AGENT_TURN_TIMEOUT_MS;
},
setWaitTimeoutMs(next: number): void {
waitTimeoutMs = next;
Expand Down
6 changes: 3 additions & 3 deletions src/loop/codex-app-server.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { spawn } from "bun";
import { AGENT_TURN_TIMEOUT_MS } from "./constants";
import { findFreePort } from "./ports";
import { DETACH_CHILD_PROCESS, killChildProcess } from "./process";
import type { Options, RunResult } from "./types";
Expand Down Expand Up @@ -42,7 +43,6 @@ const APP_SERVER_PORT_RANGE = 100;
const WS_CONNECT_ATTEMPTS = 40;
const WS_CONNECT_DELAY_MS = 150;
const USER_INPUT_TEXT_ELEMENTS = "text_elements";
const WAIT_TIMEOUT_MS = 600_000;
const NOOP_CALLBACK: Callback = () => undefined;

export const CODEX_TRANSPORT_APP_SERVER: TransportMode = "app-server";
Expand Down Expand Up @@ -460,7 +460,7 @@ class AppServerClient {
if (this.turns.delete(turnId)) {
state.reject(new Error(`codex app-server turn ${turnId} timed out`));
}
}, WAIT_TIMEOUT_MS);
}, AGENT_TURN_TIMEOUT_MS);
const clear = () => clearTimeout(timeout);
state.resolve = (result) => {
clear();
Expand Down Expand Up @@ -824,7 +824,7 @@ class AppServerClient {
const timeout = setTimeout(() => {
this.pending.delete(requestId);
reject(new Error(`codex app-server request "${method}" timed out`));
}, WAIT_TIMEOUT_MS);
}, AGENT_TURN_TIMEOUT_MS);
this.pending.set(requestId, { method, resolve, reject, timeout });
});
}
Expand Down
7 changes: 6 additions & 1 deletion src/loop/codex-render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,12 @@ const handleCompletedLine = (
state.lastCompleted = candidate;
appendChunk(state, format, write, candidate);
}
markMessageBoundary(state);
// Skip boundary when this completed event matches the item already streamed
// via deltas. The delta handler detects item changes and sets boundaries when
// a genuinely new item arrives, preventing spurious line breaks mid-stream.
if (!(sameActive && state.activeItemHasDelta)) {
markMessageBoundary(state);
}
};

export const createCodexRenderer = (
Expand Down
1 change: 1 addition & 0 deletions src/loop/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Auto-update:

export const REVIEW_PASS = "<review>PASS</review>";
export const REVIEW_FAIL = "<review>FAIL</review>";
export const AGENT_TURN_TIMEOUT_MS = 42_000_069;
Comment thread
axeldelafosse marked this conversation as resolved.
export const NEWLINE_RE = /\r?\n/;

export const VALUE_FLAGS: Record<string, ValueFlag> = {
Expand Down