






















@@ -781,70 +781,31 @@ async function verifyCodexCronMcpProbe(params: {
781781}
782782}
783783784-async function readSpawnedChildRow(params: {
784+function hasCodexAppServerLifecycleEvent(params: {
785785childSessionKey: string;
786-client: GatewayClient;
787-parentSessionKey: string;
788-}): Promise<Record<string, unknown> | undefined> {
789-const result = await params.client.request(
790-"sessions.list",
791-{
792-spawnedBy: params.parentSessionKey,
793-limit: 20,
794-},
795-{ timeoutMs: 10_000 },
786+events: CapturedAgentEvent[];
787+}): boolean {
788+return params.events.some(
789+(event) =>
790+event.sessionKey === params.childSessionKey && event.stream === "codex_app_server.lifecycle",
796791);
797-const sessions = asRecord(result)?.sessions;
798-if (!Array.isArray(sessions)) {
799-return undefined;
800-}
801-return sessions
802-.map((entry) => asRecord(entry))
803-.find((entry): entry is Record<string, unknown> => entry?.key === params.childSessionKey);
804-}
805-806-function isActiveCodexSubagentRow(row: Record<string, unknown> | undefined): boolean {
807-if (!row) {
808-return false;
809-}
810-return row.hasActiveSubagentRun === true || row.subagentRunState === "active";
811792}
812793813794async function waitForCodexSubagentStarted(params: {
814795childSessionKey: string;
815-client: GatewayClient;
816796events: CapturedAgentEvent[];
817-parentSessionKey: string;
818-}): Promise<Record<string, unknown> | undefined> {
797+}): Promise<void> {
819798const deadline = Date.now() + Math.min(CODEX_HARNESS_REQUEST_TIMEOUT_MS, 120_000);
820-let lastRow: Record<string, unknown> | undefined;
821-let lastError: unknown;
822799while (Date.now() < deadline) {
823-try {
824-lastRow = await readSpawnedChildRow({
825-childSessionKey: params.childSessionKey,
826-client: params.client,
827-parentSessionKey: params.parentSessionKey,
828-});
829-const hasLifecycleEvent = params.events.some(
830-(event) =>
831-event.sessionKey === params.childSessionKey &&
832-event.stream === "codex_app_server.lifecycle",
833-);
834-if (lastRow && (hasLifecycleEvent || isActiveCodexSubagentRow(lastRow))) {
835-return lastRow;
836-}
837-} catch (error) {
838-lastError = error;
800+if (hasCodexAppServerLifecycleEvent(params)) {
801+return;
839802}
840803await delay(2_000);
841804}
842805throw new Error(
843806[
844807`subagent ${params.childSessionKey} did not start through the Codex app-server harness`,
845-`lastRow=${JSON.stringify(lastRow)}`,
846808`events=${JSON.stringify(params.events)}`,
847-`lastError=${lastError instanceof Error ? lastError.message : String(lastError)}`,
848809].join("\n"),
849810);
850811}
@@ -937,13 +898,10 @@ async function verifyCodexSubagentProbe(params: {
937898`subagent spawn did not return a child session key: ${JSON.stringify(spawnResult)}`,
938899);
939900}
940-const childRow = await waitForCodexSubagentStarted({
901+await waitForCodexSubagentStarted({
941902 childSessionKey,
942-client: params.client,
943903 events,
944-parentSessionKey: params.sessionKey,
945904});
946-expect(childRow?.key).toBe(childSessionKey);
947905} finally {
948906const { testing: subagentSpawnTesting } = await import("../agents/subagent-spawn.js");
949907subagentSpawnTesting.setDepsForTest();
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。