mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-12 09:41:11 +00:00
perf: skip acp runtime work for no-media and no-command turns
This commit is contained in:
@@ -106,6 +106,9 @@ async function resolveAcpAttachments(
|
||||
ctx: FinalizedMsgContext,
|
||||
cfg: OpenClawConfig,
|
||||
): Promise<AcpTurnAttachment[]> {
|
||||
if (!hasInboundMediaForAcp(ctx)) {
|
||||
return [];
|
||||
}
|
||||
const {
|
||||
MediaAttachmentCache,
|
||||
isMediaUnderstandingSkipError,
|
||||
|
||||
@@ -16,7 +16,9 @@ import { tryDispatchAcpReplyHook } from "./acp-runtime.js";
|
||||
const event = {
|
||||
ctx: buildTestCtx({
|
||||
SessionKey: "agent:test:session",
|
||||
BodyForAgent: "hello",
|
||||
CommandBody: "/acp cancel",
|
||||
BodyForCommands: "/acp cancel",
|
||||
BodyForAgent: "/acp cancel",
|
||||
}),
|
||||
runId: "run-1",
|
||||
sessionKey: "agent:test:session",
|
||||
|
||||
@@ -41,10 +41,19 @@ function loadDispatchAcpRuntime() {
|
||||
return dispatchAcpRuntimePromise;
|
||||
}
|
||||
|
||||
function hasExplicitCommandCandidate(ctx: PluginHookReplyDispatchEvent["ctx"]): boolean {
|
||||
return [ctx.CommandBody, ctx.BodyForCommands].some(
|
||||
(value) => typeof value === "string" && value.trim().length > 0,
|
||||
);
|
||||
}
|
||||
|
||||
export async function tryDispatchAcpReplyHook(
|
||||
event: PluginHookReplyDispatchEvent,
|
||||
ctx: PluginHookReplyDispatchContext,
|
||||
): Promise<PluginHookReplyDispatchResult | void> {
|
||||
if (event.sendPolicy === "deny" && !hasExplicitCommandCandidate(event.ctx)) {
|
||||
return;
|
||||
}
|
||||
const runtime = await loadDispatchAcpRuntime();
|
||||
const bypassForCommand = await runtime.shouldBypassAcpDispatchForCommand(event.ctx, ctx.cfg);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user