11import { resolveSendableOutboundReplyParts } from "openclaw/plugin-sdk/reply-payload" ;
22import { isParentOwnedBackgroundAcpSession } from "../../acp/session-interaction-mode.js" ;
3- import { resolveSessionAgentId } from "../../agents/agent-scope.js" ;
3+ import { resolveAgentConfig , resolveSessionAgentId } from "../../agents/agent-scope.js" ;
44import {
55 resolveConversationBindingRecord ,
66 touchConversationBindingRecord ,
@@ -39,6 +39,7 @@ import { resolveSendPolicy } from "../../sessions/send-policy.js";
3939import { normalizeTtsAutoMode , resolveConfiguredTtsMode } from "../../tts/tts-config.js" ;
4040import { normalizeMessageChannel } from "../../utils/message-channel.js" ;
4141import type { FinalizedMsgContext } from "../templating.js" ;
42+ import { normalizeVerboseLevel } from "../thinking.js" ;
4243import {
4344 getReplyPayloadMetadata ,
4445 type BlockReplyContext ,
@@ -123,6 +124,7 @@ const resolveSessionStoreLookup = (
123124 cfg : OpenClawConfig ,
124125) : {
125126 sessionKey ?: string ;
127+ storePath ?: string ;
126128 entry ?: SessionEntry ;
127129} => {
128130 const targetSessionKey =
@@ -137,15 +139,39 @@ const resolveSessionStoreLookup = (
137139 const store = loadSessionStore ( storePath ) ;
138140 return {
139141 sessionKey,
142+ storePath,
140143 entry : resolveSessionStoreEntry ( { store, sessionKey } ) . existing ,
141144 } ;
142145 } catch {
143146 return {
144147 sessionKey,
148+ storePath,
145149 } ;
146150 }
147151} ;
148152
153+ const createShouldEmitVerboseProgress = ( params : {
154+ sessionKey ?: string ;
155+ storePath ?: string ;
156+ fallbackLevel : string ;
157+ } ) => {
158+ return ( ) => {
159+ if ( params . sessionKey && params . storePath ) {
160+ try {
161+ const store = loadSessionStore ( params . storePath ) ;
162+ const entry = resolveSessionStoreEntry ( { store, sessionKey : params . sessionKey } ) . existing ;
163+ const currentLevel = normalizeVerboseLevel ( String ( entry ?. verboseLevel ?? "" ) ) ;
164+ if ( currentLevel ) {
165+ return currentLevel !== "off" ;
166+ }
167+ } catch {
168+ // Ignore transient store read failures and fall back to the current dispatch snapshot.
169+ }
170+ }
171+ return params . fallbackLevel !== "off" ;
172+ } ;
173+ } ;
174+
149175export type DispatchFromConfigResult = {
150176 queuedFinal : boolean ;
151177 counts : Record < ReplyDispatchKind , number > ;
@@ -221,6 +247,21 @@ export async function dispatchReplyFromConfig(params: {
221247
222248 const sessionStoreEntry = resolveSessionStoreLookup ( ctx , cfg ) ;
223249 const acpDispatchSessionKey = sessionStoreEntry . sessionKey ?? sessionKey ;
250+ const sessionAgentId = resolveSessionAgentId ( { sessionKey : acpDispatchSessionKey , config : cfg } ) ;
251+ const sessionAgentCfg = resolveAgentConfig ( cfg , sessionAgentId ) ;
252+ const shouldEmitVerboseProgress = createShouldEmitVerboseProgress ( {
253+ sessionKey : acpDispatchSessionKey ,
254+ storePath : sessionStoreEntry . storePath ,
255+ fallbackLevel :
256+ normalizeVerboseLevel (
257+ String (
258+ sessionStoreEntry . entry ?. verboseLevel ??
259+ sessionAgentCfg ?. verboseDefault ??
260+ cfg . agents ?. defaults ?. verboseDefault ??
261+ "" ,
262+ ) ,
263+ ) ?? "off" ,
264+ } ) ;
224265 // Restore route thread context only from the active turn or the thread-scoped session key.
225266 // Do not read thread ids from the normalised session store here: `origin.threadId` can be
226267 // folded back into lastThreadId/deliveryContext during store normalisation and resurrect a
@@ -650,6 +691,7 @@ export async function dispatchReplyFromConfig(params: {
650691 const maybeSendWorkingStatus = ( label : string ) => {
651692 const normalizedLabel = normalizeWorkingLabel ( label ) ;
652693 if (
694+ ! shouldEmitVerboseProgress ( ) ||
653695 ! shouldSendToolStartStatuses ||
654696 ! normalizedLabel ||
655697 toolStartStatusCount >= 2 ||
@@ -668,6 +710,9 @@ export async function dispatchReplyFromConfig(params: {
668710 dispatcher . sendToolResult ( payload ) ;
669711 } ;
670712 const sendPlanUpdate = ( payload : { explanation ?: string ; steps ?: string [ ] } ) => {
713+ if ( ! shouldEmitVerboseProgress ( ) ) {
714+ return ;
715+ }
671716 const replyPayload : ReplyPayload = {
672717 text : formatPlanUpdateText ( payload ) ,
673718 } ;
0 commit comments