-
Notifications
You must be signed in to change notification settings - Fork 116
Devin/add action cache #74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| createdAt: startTime, | ||
| status: TaskStatus.COMPLETED, | ||
| steps: [], | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Single action returns empty actionCache steps array
The executeSingleAction method returns an actionCache with an empty steps array, even though the action was successfully executed and all necessary data (element ID, method, arguments, xpath, instruction) is available. This makes the returned action cache unusable for replay via runFromActionCache, which iterates over the steps array. Unlike runAgentTask which properly builds cache entries using buildActionCacheEntry, this method doesn't populate the steps.
|
@claude can you review |
|
Claude finished @Dingway98's task —— View job Code Review CompleteI've thoroughly reviewed the action cache implementation. Here are my findings: Critical Issues (Confirmed from Cursor Reviews)1. Action cache written unconditionally bypassing debug check
|
|
|
||
| if (step.actionType === "extract") { | ||
| return `${indent}// Step ${step.stepIndex} | ||
| ${indent}await page.extract("${step.instruction}");`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Unescaped string interpolation breaks generated scripts
The step.instruction value is directly interpolated into the generated script string using "${step.instruction}" instead of JSON.stringify(step.instruction). If the instruction contains double quotes, backslashes, or newlines, the generated script will have invalid JavaScript syntax. Other string values in the same file (like urlArg, step.xpath, and value) are correctly escaped with JSON.stringify(), but this case was missed for the extract action type.
| ❌ Cached XPath Failed: "${cachedXPath}" | ||
| ✅ LLM Resolved New XPath: "${resolvedXPath}" | ||
| ` | ||
| ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Unconditional console.log ignores debug flag
The console.log statement is executed unconditionally when a cached action falls back to LLM, even though a debug parameter is available in scope (destructured at line 44). The rest of the codebase consistently gates console logging behind debug checks. This will cause verbose output in production when users have debug mode disabled.
| public async runFromActionCache( | ||
| cache: ActionCacheOutput, | ||
| pageOrGetter: Page | (() => Page), | ||
| params?: RunFromActionCacheParams |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Method signature accepts Page but requires HyperPage internally
The public runFromActionCache method accepts pageOrGetter: Page | (() => Page) but internally casts the page to HyperPage and calls methods that only exist on HyperPage, not on the base Playwright Page. Specifically, hyperPage.extract() and hyperPage.perform() are called, as well as dispatchPerformHelper which invokes performClick, performFill, etc. If a caller passes a plain Playwright Page directly to agent.runFromActionCache(), they'll get runtime errors like "extract is not a function". The type signature is misleading.
Note
Introduces first-class action cache capture and replay, adds
HyperPageperform helpers, script generation from cache, XPath→CDP resolution, and extends types/outputs to include cache metadata.runAgentTaskand persist to debug; store by task viagetActionCache.runFromActionCacheto replay cached steps (with XPath/CDP resolution, retries, optional LLM fallback) and write replay debug.HyperPage(performClick/fill/type/press/selectOptionFromDropdown/check/uncheck/hover/scrollToElement/scrollToPercentage/nextChunk/prevChunk).createScriptFromActionCacheto emit executable scripts from cached steps.shared/run-cached-action.tsandshared/xpath-cdp-resolver.ts.ActionCacheEntry,ActionCacheOutput,ActionCacheReplayResult,ActionCacheReplayStepResult,ReplayStepMeta,PerformOptions,AgentTaskOutput.TaskOutputwithtaskIdand optionalactionCache;HyperPage.ainow returnsAgentTaskOutput;Taskincludesid.1.0.9.Written by Cursor Bugbot for commit caa1e94. This will update automatically on new commits. Configure here.