mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-17 05:20:47 +00:00
35 lines
846 B
TypeScript
35 lines
846 B
TypeScript
import type { OpenClawConfig } from "../config/types.openclaw.js";
|
|
import type { ToolLoopDetectionConfig } from "../config/types.tools.js";
|
|
import { resolveAgentConfig } from "./agent-scope.js";
|
|
|
|
export function resolveToolLoopDetectionConfig(params: {
|
|
cfg?: OpenClawConfig;
|
|
agentId?: string;
|
|
}): ToolLoopDetectionConfig | undefined {
|
|
const global = params.cfg?.tools?.loopDetection;
|
|
const agent =
|
|
params.agentId && params.cfg
|
|
? resolveAgentConfig(params.cfg, params.agentId)?.tools?.loopDetection
|
|
: undefined;
|
|
|
|
if (!agent) {
|
|
return global;
|
|
}
|
|
if (!global) {
|
|
return agent;
|
|
}
|
|
|
|
return {
|
|
...global,
|
|
...agent,
|
|
detectors: {
|
|
...global.detectors,
|
|
...agent.detectors,
|
|
},
|
|
postCompactionGuard: {
|
|
...global.postCompactionGuard,
|
|
...agent.postCompactionGuard,
|
|
},
|
|
};
|
|
}
|