mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-08 20:54:02 +00:00
41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
/**
|
|
* Tool loop-detection config resolver.
|
|
* Overlays per-agent loop detection settings on global tool defaults while
|
|
* preserving nested detector and post-compaction guard fields.
|
|
*/
|
|
import type { OpenClawConfig } from "../config/types.openclaw.js";
|
|
import type { ToolLoopDetectionConfig } from "../config/types.tools.js";
|
|
import { resolveAgentConfig } from "./agent-scope.js";
|
|
|
|
/** Resolves effective tool loop-detection config by overlaying agent settings on globals. */
|
|
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,
|
|
},
|
|
};
|
|
}
|