@@ -76,6 +76,13 @@ export async function runCachedStep(
7676
7777 const taskId = uuidv4 ( ) ;
7878 const attempts = normalizeMaxSteps ( maxSteps ) ;
79+ const normalizedXPath = cachedAction . xpath ?. trim ( ) ;
80+ const normalizedMethod = cachedAction . method ?. trim ( ) ;
81+ const normalizedCachedAction : CachedActionInput = {
82+ ...cachedAction ,
83+ xpath : normalizedXPath ,
84+ method : normalizedMethod ,
85+ } ;
7986
8087 const specialActionResult = await executeReplaySpecialAction ( {
8188 taskId,
@@ -98,7 +105,7 @@ export async function runCachedStep(
98105 usedCachedAction : true ,
99106 fallbackUsed : false ,
100107 retries : 1 ,
101- cachedXPath : cachedAction . xpath ?? null ,
108+ cachedXPath : normalizedXPath ?? null ,
102109 fallbackXPath : null ,
103110 fallbackElementId : null ,
104111 } ,
@@ -110,8 +117,8 @@ export async function runCachedStep(
110117
111118 if (
112119 cachedAction . actionType !== "actElement" ||
113- ! cachedAction . xpath ||
114- ! cachedAction . method
120+ ! normalizedXPath ||
121+ ! normalizedMethod
115122 ) {
116123 return {
117124 taskId,
@@ -128,7 +135,7 @@ export async function runCachedStep(
128135 const attemptResult = await runCachedAttempt ( {
129136 page,
130137 instruction,
131- cachedAction,
138+ cachedAction : normalizedCachedAction ,
132139 debug,
133140 tokenLimit,
134141 llm,
@@ -165,7 +172,7 @@ export async function runCachedStep(
165172 usedCachedAction : true ,
166173 fallbackUsed : false ,
167174 retries : attemptIndex ,
168- cachedXPath : cachedAction . xpath ?? null ,
175+ cachedXPath : normalizedXPath ?? null ,
169176 fallbackXPath : null ,
170177 fallbackElementId : null ,
171178 } ,
@@ -186,14 +193,14 @@ export async function runCachedStep(
186193 usedCachedAction : true ,
187194 fallbackUsed : true ,
188195 retries : attempts ,
189- cachedXPath : cachedAction . xpath ?? null ,
196+ cachedXPath : normalizedXPath ?? null ,
190197 fallbackXPath : null ,
191198 fallbackElementId : null ,
192199 } ,
193200 } satisfies TaskOutput ;
194201 } ) ;
195202 if ( debug ) {
196- const cachedXPath = cachedAction . xpath || "N/A" ;
203+ const cachedXPath = normalizedXPath || "N/A" ;
197204 const resolvedXPath = fb . replayStepMeta ?. fallbackXPath || "N/A" ;
198205 // eslint-disable-next-line no-console
199206 console . log (
@@ -211,7 +218,7 @@ export async function runCachedStep(
211218 usedCachedAction : true ,
212219 fallbackUsed : true ,
213220 retries : attempts ,
214- cachedXPath : cachedAction . xpath ?? null ,
221+ cachedXPath : normalizedXPath ?? null ,
215222 fallbackXPath : fb . replayStepMeta ?. fallbackXPath ?? null ,
216223 fallbackElementId : fb . replayStepMeta ?. fallbackElementId ?? null ,
217224 } ,
@@ -230,7 +237,7 @@ export async function runCachedStep(
230237 usedCachedAction : true ,
231238 fallbackUsed : false ,
232239 retries : attempts ,
233- cachedXPath : cachedAction . xpath ?? null ,
240+ cachedXPath : normalizedXPath ?? null ,
234241 fallbackXPath : null ,
235242 fallbackElementId : null ,
236243 } ,
0 commit comments