mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-27 22:42:31 +00:00
fix: resolve post-rebase agent runtime drift
This commit is contained in:
@@ -94,7 +94,7 @@ async function deferOwningContextEngineBudgetCompaction(params: {
|
||||
compactParams: CompactEmbeddedAgentSessionParams;
|
||||
contextEngine: ContextEngine;
|
||||
contextEngineRuntimeContext: ContextEngineRuntimeContext;
|
||||
}): Promise<EmbeddedPiCompactResult> {
|
||||
}): Promise<EmbeddedAgentCompactResult> {
|
||||
let deferredScheduled = false;
|
||||
let deferredScheduleFailure: unknown;
|
||||
try {
|
||||
|
||||
@@ -722,7 +722,7 @@ async function compactEmbeddedAgentSessionDirectOnce(
|
||||
model: effectiveModel,
|
||||
modelApi: effectiveModel.api,
|
||||
harnessId: params.agentHarnessId,
|
||||
harnessRuntime: selectedHarnessRuntime,
|
||||
harnessRuntime: runtimeHarnessPolicy.runtime,
|
||||
authProfileProvider: authProfileId?.split(":", 1)[0],
|
||||
sessionAuthProfileId: authProfileId,
|
||||
config: params.config,
|
||||
|
||||
@@ -15,8 +15,6 @@ import { privateFileStoreSync } from "../../infra/private-file-store.js";
|
||||
import { createSubsystemLogger } from "../../logging/subsystem.js";
|
||||
import { hasGlobalHooks } from "../../plugins/hook-runner-global.js";
|
||||
import { PluginApprovalResolutions } from "../../plugins/types.js";
|
||||
import { uniqueValues } from "../../shared/string-normalization.js";
|
||||
import { asBoolean } from "../../utils/boolean.js";
|
||||
import { hasBeforeToolCallPolicy, runBeforeToolCallHook } from "../agent-tools.before-tool-call.js";
|
||||
import { stableStringify } from "../stable-stringify.js";
|
||||
import { resolveToolLoopDetectionConfig } from "../tool-loop-detection-config.js";
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
import { createHash } from "node:crypto";
|
||||
import type { AgentMessage } from "./runtime/index.js";
|
||||
import {
|
||||
hasUnredactedSessionsSpawnAttachments,
|
||||
isAllowedToolCallName,
|
||||
normalizeAllowedToolNames,
|
||||
} from "./tool-call-shared.js";
|
||||
import { isAllowedToolCallName, normalizeAllowedToolNames } from "./tool-call-shared.js";
|
||||
|
||||
export type ToolCallIdMode = "strict" | "strict9";
|
||||
const NATIVE_ANTHROPIC_TOOL_USE_ID_RE = /^toolu_[A-Za-z0-9_]+$/;
|
||||
|
||||
@@ -17,20 +17,6 @@ import {
|
||||
import { resolveBootstrapWarningSignaturesSeen } from "../../agents/bootstrap-budget.js";
|
||||
import { getCliSessionBinding } from "../../agents/cli-session.js";
|
||||
import { resolveContextTokensForModel } from "../../agents/context.js";
|
||||
import { ensureSelectedAgentHarnessPlugin } from "../../agents/harness/runtime-plugin.js";
|
||||
import { resolveAgentHarnessPolicy } from "../../agents/harness/selection.js";
|
||||
import { LiveSessionModelSwitchError } from "../../agents/live-model-switch-error.js";
|
||||
import { runWithModelFallback, isFallbackSummaryError } from "../../agents/model-fallback.js";
|
||||
import {
|
||||
listLegacyRuntimeModelProviderAliases,
|
||||
resolveCliRuntimeExecutionProvider,
|
||||
} from "../../agents/model-runtime-aliases.js";
|
||||
import {
|
||||
isCliProvider,
|
||||
resolveModelRefFromString,
|
||||
resolvePersistedOverrideModelRef,
|
||||
} from "../../agents/model-selection.js";
|
||||
import { resolveOpenAIRuntimeProvider } from "../../agents/openai-codex-routing.js";
|
||||
import {
|
||||
BILLING_ERROR_USER_MESSAGE,
|
||||
formatRateLimitOrOverloadedErrorCopy,
|
||||
@@ -45,6 +31,17 @@ import {
|
||||
import { sanitizeUserFacingText } from "../../agents/embedded-agent-helpers/sanitize-user-facing-text.js";
|
||||
import { isMessagingToolSendAction } from "../../agents/embedded-agent-messaging.js";
|
||||
import { runEmbeddedAgent } from "../../agents/embedded-agent.js";
|
||||
import { ensureSelectedAgentHarnessPlugin } from "../../agents/harness/runtime-plugin.js";
|
||||
import { resolveAgentHarnessPolicy } from "../../agents/harness/selection.js";
|
||||
import { LiveSessionModelSwitchError } from "../../agents/live-model-switch-error.js";
|
||||
import { runWithModelFallback, isFallbackSummaryError } from "../../agents/model-fallback.js";
|
||||
import { resolveCliRuntimeExecutionProvider } from "../../agents/model-runtime-aliases.js";
|
||||
import {
|
||||
isCliProvider,
|
||||
resolveModelRefFromString,
|
||||
resolvePersistedOverrideModelRef,
|
||||
} from "../../agents/model-selection.js";
|
||||
import { resolveOpenAIRuntimeProvider } from "../../agents/openai-codex-routing.js";
|
||||
import { buildAgentRuntimeOutcomePlan } from "../../agents/runtime-plan/build.js";
|
||||
import {
|
||||
resolveGroupSessionKey,
|
||||
@@ -1305,11 +1302,7 @@ export function resolveSessionRuntimeOverrideForProvider(params: {
|
||||
if (provider === "openai" && runtime === "codex") {
|
||||
return "codex";
|
||||
}
|
||||
return listLegacyRuntimeModelProviderAliases().find(
|
||||
(alias) =>
|
||||
normalizeLowercaseStringOrEmpty(alias.provider) === provider &&
|
||||
normalizeLowercaseStringOrEmpty(alias.runtime) === runtime,
|
||||
)?.runtime;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export function resolveRunAfterAutoFallbackPrimaryProbeRecheck(params: {
|
||||
|
||||
@@ -1164,7 +1164,7 @@ describe("runMemoryFlushIfNeeded", () => {
|
||||
expect(refreshQueuedFollowupSessionMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("uses the persisted Codex runtime context window for OpenAI preflight compaction", async () => {
|
||||
it("skips OpenClaw preflight compaction for persisted Codex runtime sessions", async () => {
|
||||
registerMemoryFlushPlanResolverForTest(() => ({
|
||||
softThresholdTokens: 4_000,
|
||||
forceFlushTranscriptBytes: 1_000_000_000,
|
||||
@@ -1181,7 +1181,7 @@ describe("runMemoryFlushIfNeeded", () => {
|
||||
agentHarnessId: "codex",
|
||||
};
|
||||
|
||||
await runPreflightCompactionIfNeeded({
|
||||
const entry = await runPreflightCompactionIfNeeded({
|
||||
cfg: {
|
||||
models: {
|
||||
providers: {
|
||||
@@ -1206,12 +1206,11 @@ describe("runMemoryFlushIfNeeded", () => {
|
||||
replyOperation: createReplyOperation(),
|
||||
});
|
||||
|
||||
expect(compactEmbeddedAgentSessionMock).toHaveBeenCalledTimes(1);
|
||||
const compactCall = requireCompactEmbeddedAgentSessionCall();
|
||||
expect(compactCall.currentTokenCount).toBe(347_000);
|
||||
expect(entry).toBe(sessionEntry);
|
||||
expect(compactEmbeddedAgentSessionMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("still compacts when a fresh persisted token total is over the threshold", async () => {
|
||||
it("skips fresh persisted token totals for persisted Codex runtime sessions", async () => {
|
||||
registerMemoryFlushPlanResolverForTest(() => ({
|
||||
softThresholdTokens: 4_000,
|
||||
forceFlushTranscriptBytes: 1_000_000_000,
|
||||
@@ -1228,7 +1227,7 @@ describe("runMemoryFlushIfNeeded", () => {
|
||||
agentHarnessId: "codex",
|
||||
};
|
||||
|
||||
await runPreflightCompactionIfNeeded({
|
||||
const entry = await runPreflightCompactionIfNeeded({
|
||||
cfg: {
|
||||
models: {
|
||||
providers: {
|
||||
@@ -1253,9 +1252,8 @@ describe("runMemoryFlushIfNeeded", () => {
|
||||
replyOperation: createReplyOperation(),
|
||||
});
|
||||
|
||||
expect(compactEmbeddedAgentSessionMock).toHaveBeenCalledTimes(1);
|
||||
const compactCall = requireCompactEmbeddedAgentSessionCall();
|
||||
expect(compactCall.currentTokenCount).toBe(347_000);
|
||||
expect(entry).toBe(sessionEntry);
|
||||
expect(compactEmbeddedAgentSessionMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("keeps the OpenAI API context window for persisted OpenClaw runtime overrides", async () => {
|
||||
|
||||
@@ -1,19 +1,18 @@
|
||||
import crypto from "node:crypto";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import type { AgentMessage } from "../../agents/runtime/index.js";
|
||||
import { resolveBootstrapWarningSignaturesSeen } from "../../agents/bootstrap-budget.js";
|
||||
import { estimateMessagesTokens } from "../../agents/compaction.js";
|
||||
import { resolveAgentHarnessPolicy } from "../../agents/harness/policy.js";
|
||||
import { ensureSelectedAgentHarnessPlugin } from "../../agents/harness/runtime-plugin.js";
|
||||
import { runWithModelFallback } from "../../agents/model-fallback.js";
|
||||
import { listLegacyRuntimeModelProviderAliases } from "../../agents/model-runtime-aliases.js";
|
||||
import { isCliProvider } from "../../agents/model-selection.js";
|
||||
import { resolveContextConfigProviderForRuntime } from "../../agents/openai-codex-routing.js";
|
||||
import {
|
||||
classifyCompactionReason,
|
||||
DEFERRED_CONTEXT_ENGINE_COMPACTION_REASON,
|
||||
} from "../../agents/embedded-agent-runner/compact-reasons.js";
|
||||
import { resolveAgentHarnessPolicy } from "../../agents/harness/policy.js";
|
||||
import { ensureSelectedAgentHarnessPlugin } from "../../agents/harness/runtime-plugin.js";
|
||||
import { runWithModelFallback } from "../../agents/model-fallback.js";
|
||||
import { isCliProvider } from "../../agents/model-selection.js";
|
||||
import { resolveContextConfigProviderForRuntime } from "../../agents/openai-codex-routing.js";
|
||||
import type { AgentMessage } from "../../agents/runtime/index.js";
|
||||
import { resolveSandboxConfigForAgent, resolveSandboxRuntimeStatus } from "../../agents/sandbox.js";
|
||||
import {
|
||||
derivePromptTokens,
|
||||
@@ -240,11 +239,7 @@ function resolveMemoryFlushRuntimeOverrideForProvider(params: {
|
||||
if (provider === "openai" && runtime === "codex") {
|
||||
return "codex";
|
||||
}
|
||||
return listLegacyRuntimeModelProviderAliases().find(
|
||||
(alias) =>
|
||||
normalizeLowercaseStringOrEmpty(alias.provider) === provider &&
|
||||
normalizeLowercaseStringOrEmpty(alias.runtime) === runtime,
|
||||
)?.runtime;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function resolveFollowupContextConfigProvider(params: {
|
||||
|
||||
@@ -191,7 +191,7 @@ describe("handleCompactCommand", () => {
|
||||
});
|
||||
|
||||
it("treats already-under-target manual compaction as skipped", async () => {
|
||||
vi.mocked(compactEmbeddedPiSession).mockResolvedValueOnce({
|
||||
vi.mocked(compactEmbeddedAgentSession).mockResolvedValueOnce({
|
||||
ok: false,
|
||||
compacted: false,
|
||||
reason: "already under target",
|
||||
|
||||
@@ -13,8 +13,7 @@ import { formatErrorMessage } from "../infra/errors.js";
|
||||
import { readConfiguredLogTail } from "../logging/log-tail.js";
|
||||
import { parseLogLine } from "../logging/parse-log-line.js";
|
||||
import { redactSensitiveLines, resolveRedactOptions } from "../logging/redact.js";
|
||||
import { formatTimestamp, isValidTimeZone } from "../logging/timestamps.js";
|
||||
import { createLazyImportLoader } from "../shared/lazy-promise.js";
|
||||
import { formatTimestamp } from "../logging/timestamps.js";
|
||||
import { normalizeLowercaseStringOrEmpty } from "../shared/string-coerce.js";
|
||||
import { formatDocsLink } from "../terminal/links.js";
|
||||
import { clearActiveProgressLine } from "../terminal/progress-line.js";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { isAuthErrorMessage } from "../agents/embedded-agent-helpers.js";
|
||||
import { classifyFailoverReason, isAuthErrorMessage } from "../agents/embedded-agent-helpers.js";
|
||||
import { parseAgentSessionKey } from "../sessions/session-key-utils.js";
|
||||
import { formatRawAssistantErrorForUi } from "../shared/assistant-error-format.js";
|
||||
import { normalizeLowercaseStringOrEmpty } from "../shared/string-coerce.js";
|
||||
|
||||
Reference in New Issue
Block a user