fix: use inline setInterval instead of EventLoopKeepalive import

EventLoopKeepalive is not exported from yield.ts on main.
Use setInterval + unref() directly, matching the pattern in
keepaliveWhile(). Biome import order also fixed (type imports
before value imports within the same group).
This commit is contained in:
hezhiyang2000
2026-05-28 11:51:24 +08:00
parent 38d77f819d
commit af2011f5a1
+3 -3
View File
@@ -34,7 +34,6 @@ import type {
StreamFn,
ToolCallContext,
} from "./types";
import { EventLoopKeepalive } from "./utils/yield";
/**
* Default convertToLlm: Keep only LLM-compatible messages, convert attachments.
@@ -858,7 +857,8 @@ export class Agent {
if (!model) throw new Error("No model configured");
let skipInitialSteeringPoll = options?.skipInitialSteeringPoll === true;
const keepalive = new EventLoopKeepalive();
const keepalive = setInterval(() => {}, 86_400_000);
keepalive.unref();
const { promise, resolve } = Promise.withResolvers<void>();
this.#runningPrompt = promise;
this.#resolveRunningPrompt = resolve;
@@ -1063,7 +1063,7 @@ export class Agent {
this.#state.error = err?.message || String(err);
this.#emit({ type: "agent_end", messages: [errorMsg] });
} finally {
keepalive.dispose();
clearInterval(keepalive);
this.#state.isStreaming = false;
this.#state.streamMessage = null;
this.#state.pendingToolCalls = new Set<string>();