fix(agents): honor embedded ollama timeouts (#66418)

This commit is contained in:
Vincent Koc
2026-04-14 09:21:22 +01:00
committed by GitHub
parent 900681751d
commit 38de896419
4 changed files with 56 additions and 3 deletions

View File

@@ -8,6 +8,7 @@ Docs: https://docs.openclaw.ai
### Fixes
- Agents/Ollama: forward the configured embedded-run timeout into the global undici stream timeout tuning so slow local Ollama runs no longer inherit the default stream cutoff instead of the operator-set run timeout. (#63175) Thanks @mindcraftreader and @vincentkoc.
- Models/Codex: include `apiKey` in the codex provider catalog output so the Pi ModelRegistry validator no longer rejects the entry and silently drops all custom models from every provider in `models.json`. (#66180) Thanks @hoyyeva.
- Slack/interactions: apply the configured global `allowFrom` owner allowlist to channel block-action and modal interactive events, require an expected sender id for cross-verification, and reject ambiguous channel types so interactive triggers can no longer bypass the documented allowlist intent in channels without a `users` list. Open-by-default behavior is preserved when no allowlists are configured. (#66028) Thanks @eleqtrizit.
- Media-understanding/attachments: fail closed when a local attachment path cannot be canonically resolved via `realpath`, so a `realpath` error can no longer downgrade the canonical-roots allowlist check to a non-canonical comparison; attachments that also have a URL still fall back to the network fetch path. (#66022) Thanks @eleqtrizit.

View File

@@ -47,6 +47,8 @@ type AttemptSpawnWorkspaceHoisted = {
createAgentSessionMock: UnknownMock;
sessionManagerOpenMock: UnknownMock;
resolveSandboxContextMock: UnknownMock;
ensureGlobalUndiciEnvProxyDispatcherMock: UnknownMock;
ensureGlobalUndiciStreamTimeoutsMock: UnknownMock;
buildEmbeddedMessageActionDiscoveryInputMock: UnknownMock;
subscribeEmbeddedPiSessionMock: Mock<SubscribeEmbeddedPiSessionFn>;
acquireSessionWriteLockMock: Mock<AcquireSessionWriteLockFn>;
@@ -71,6 +73,8 @@ const hoisted = vi.hoisted((): AttemptSpawnWorkspaceHoisted => {
const createAgentSessionMock = vi.fn();
const sessionManagerOpenMock = vi.fn();
const resolveSandboxContextMock = vi.fn();
const ensureGlobalUndiciEnvProxyDispatcherMock = vi.fn();
const ensureGlobalUndiciStreamTimeoutsMock = vi.fn();
const buildEmbeddedMessageActionDiscoveryInputMock = vi.fn((params: unknown) => params);
const installToolResultContextGuardMock = vi.fn(() => () => {});
const flushPendingToolResultsAfterIdleMock = vi.fn(async () => {});
@@ -135,6 +139,8 @@ const hoisted = vi.hoisted((): AttemptSpawnWorkspaceHoisted => {
createAgentSessionMock,
sessionManagerOpenMock,
resolveSandboxContextMock,
ensureGlobalUndiciEnvProxyDispatcherMock,
ensureGlobalUndiciStreamTimeoutsMock,
buildEmbeddedMessageActionDiscoveryInputMock,
subscribeEmbeddedPiSessionMock,
acquireSessionWriteLockMock,
@@ -209,8 +215,10 @@ vi.mock("../../../infra/machine-name.js", () => ({
}));
vi.mock("../../../infra/net/undici-global-dispatcher.js", () => ({
ensureGlobalUndiciEnvProxyDispatcher: () => {},
ensureGlobalUndiciStreamTimeouts: () => {},
ensureGlobalUndiciEnvProxyDispatcher: (...args: unknown[]) =>
hoisted.ensureGlobalUndiciEnvProxyDispatcherMock(...args),
ensureGlobalUndiciStreamTimeouts: (...args: unknown[]) =>
hoisted.ensureGlobalUndiciStreamTimeoutsMock(...args),
}));
vi.mock("../../bootstrap-files.js", async () => {
@@ -683,6 +691,8 @@ export function resetEmbeddedAttemptHarness(
hoisted.createAgentSessionMock.mockReset();
hoisted.sessionManagerOpenMock.mockReset().mockReturnValue(hoisted.sessionManager);
hoisted.resolveSandboxContextMock.mockReset();
hoisted.ensureGlobalUndiciEnvProxyDispatcherMock.mockReset();
hoisted.ensureGlobalUndiciStreamTimeoutsMock.mockReset();
hoisted.buildEmbeddedMessageActionDiscoveryInputMock
.mockReset()
.mockImplementation((params) => params);

View File

@@ -0,0 +1,42 @@
import { afterEach, beforeEach, describe, expect, it } from "vitest";
import {
cleanupTempPaths,
createContextEngineAttemptRunner,
getHoisted,
resetEmbeddedAttemptHarness,
} from "./attempt.spawn-workspace.test-support.js";
const hoisted = getHoisted();
describe("runEmbeddedAttempt undici timeout wiring", () => {
const tempPaths: string[] = [];
beforeEach(() => {
resetEmbeddedAttemptHarness();
});
afterEach(async () => {
await cleanupTempPaths(tempPaths);
});
it("forwards the configured run timeout into global undici stream tuning", async () => {
await createContextEngineAttemptRunner({
sessionKey: "agent:main:ollama-timeout-test",
tempPaths,
contextEngine: {
assemble: async ({ messages }) => ({
messages,
estimatedTokens: 1,
}),
},
attemptOverrides: {
timeoutMs: 123_456,
},
});
expect(hoisted.ensureGlobalUndiciEnvProxyDispatcherMock).toHaveBeenCalledOnce();
expect(hoisted.ensureGlobalUndiciStreamTimeoutsMock).toHaveBeenCalledWith({
timeoutMs: 123_456,
});
});
});

View File

@@ -361,7 +361,7 @@ export async function runEmbeddedAttempt(
// Proxy bootstrap must happen before timeout tuning so the timeouts wrap the
// active EnvHttpProxyAgent instead of being replaced by a bare proxy dispatcher.
ensureGlobalUndiciEnvProxyDispatcher();
ensureGlobalUndiciStreamTimeouts();
ensureGlobalUndiciStreamTimeouts({ timeoutMs: params.timeoutMs });
log.debug(
`embedded run start: runId=${params.runId} sessionId=${params.sessionId} provider=${params.provider} model=${params.modelId} thinking=${params.thinkLevel} messageChannel=${params.messageChannel ?? params.messageProvider ?? "unknown"}`,