mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-31 11:23:33 +00:00
refactor: neutralize context engine runtime bridge
This commit is contained in:
@@ -933,7 +933,7 @@ export async function compactEmbeddedPiSession(
|
||||
tokenBudget: ceCtxInfo.tokens,
|
||||
customInstructions: params.customInstructions,
|
||||
force: params.trigger === "manual",
|
||||
legacyParams: params as Record<string, unknown>,
|
||||
runtimeContext: params as Record<string, unknown>,
|
||||
});
|
||||
return {
|
||||
ok: result.ok,
|
||||
|
||||
@@ -1025,7 +1025,7 @@ export async function runEmbeddedPiAgent(
|
||||
tokenBudget: ctxInfo.tokens,
|
||||
force: true,
|
||||
compactionTarget: "budget",
|
||||
legacyParams: {
|
||||
runtimeContext: {
|
||||
sessionKey: params.sessionKey,
|
||||
messageChannel: params.messageChannel,
|
||||
messageProvider: params.messageProvider,
|
||||
|
||||
@@ -2,7 +2,7 @@ import { describe, expect, it, vi } from "vitest";
|
||||
import type { OpenClawConfig } from "../../../config/config.js";
|
||||
import { resolveOllamaBaseUrlForRun } from "../../ollama-stream.js";
|
||||
import {
|
||||
buildAfterTurnLegacyCompactionParams,
|
||||
buildAfterTurnRuntimeContext,
|
||||
composeSystemPromptWithHookContext,
|
||||
isOllamaCompatProvider,
|
||||
prependSystemPromptAddition,
|
||||
@@ -638,9 +638,9 @@ describe("prependSystemPromptAddition", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("buildAfterTurnLegacyCompactionParams", () => {
|
||||
describe("buildAfterTurnRuntimeContext", () => {
|
||||
it("uses primary model when compaction.model is not set", () => {
|
||||
const legacy = buildAfterTurnLegacyCompactionParams({
|
||||
const legacy = buildAfterTurnRuntimeContext({
|
||||
attempt: {
|
||||
sessionKey: "agent:main:session:abc",
|
||||
messageChannel: "slack",
|
||||
@@ -668,7 +668,7 @@ describe("buildAfterTurnLegacyCompactionParams", () => {
|
||||
});
|
||||
|
||||
it("passes primary model through even when compaction.model is set (override resolved in compactDirect)", () => {
|
||||
const legacy = buildAfterTurnLegacyCompactionParams({
|
||||
const legacy = buildAfterTurnRuntimeContext({
|
||||
attempt: {
|
||||
sessionKey: "agent:main:session:abc",
|
||||
messageChannel: "slack",
|
||||
@@ -704,9 +704,8 @@ describe("buildAfterTurnLegacyCompactionParams", () => {
|
||||
model: "gpt-5.3-codex",
|
||||
});
|
||||
});
|
||||
|
||||
it("includes resolved auth profile fields for context-engine afterTurn compaction", () => {
|
||||
const legacy = buildAfterTurnLegacyCompactionParams({
|
||||
const legacy = buildAfterTurnRuntimeContext({
|
||||
attempt: {
|
||||
sessionKey: "agent:main:session:abc",
|
||||
messageChannel: "slack",
|
||||
|
||||
@@ -636,8 +636,8 @@ export function prependSystemPromptAddition(params: {
|
||||
return `${params.systemPromptAddition}\n\n${params.systemPrompt}`;
|
||||
}
|
||||
|
||||
/** Build legacy compaction params passed into context-engine afterTurn hooks. */
|
||||
export function buildAfterTurnLegacyCompactionParams(params: {
|
||||
/** Build runtime context passed into context-engine afterTurn hooks. */
|
||||
export function buildAfterTurnRuntimeContext(params: {
|
||||
attempt: Pick<
|
||||
EmbeddedRunAttemptParams,
|
||||
| "sessionKey"
|
||||
@@ -1884,7 +1884,7 @@ export async function runEmbeddedAttempt(
|
||||
|
||||
// Let the active context engine run its post-turn lifecycle.
|
||||
if (params.contextEngine) {
|
||||
const afterTurnLegacyCompactionParams = buildAfterTurnLegacyCompactionParams({
|
||||
const afterTurnRuntimeContext = buildAfterTurnRuntimeContext({
|
||||
attempt: params,
|
||||
workspaceDir: effectiveWorkspace,
|
||||
agentDir,
|
||||
@@ -1898,7 +1898,7 @@ export async function runEmbeddedAttempt(
|
||||
messages: messagesSnapshot,
|
||||
prePromptMessageCount,
|
||||
tokenBudget: params.contextTokenBudget,
|
||||
legacyCompactionParams: afterTurnLegacyCompactionParams,
|
||||
runtimeContext: afterTurnRuntimeContext,
|
||||
});
|
||||
} catch (afterTurnErr) {
|
||||
log.warn(`context engine afterTurn failed: ${String(afterTurnErr)}`);
|
||||
|
||||
Reference in New Issue
Block a user