-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Fix: Pass variables to buildActPrompt during self-heal #1537
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
base: main
Are you sure you want to change the base?
Fix: Pass variables to buildActPrompt during self-heal #1537
Conversation
When an action fails and self-heal is triggered, the retry call to
buildActPrompt was passing an empty object {} instead of the variables
parameter that's available in scope. This meant the LLM didn't know
about available variable placeholders during self-heal attempts.
The fix changes line 368 from {} to variables, ensuring consistent
behavior between the initial attempt and self-heal retries.
Fixes BUG-024: Self-Heal Loop Uses Empty Variables Object
|
Greptile SummaryFixed a bug where the self-heal retry mechanism was passing an empty object
Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant ActHandler
participant buildActPrompt
participant LLM
participant performUnderstudyMethod
User->>ActHandler: act("type %password%", {variables: {password: "secret"}})
Note over ActHandler: Initial attempt
ActHandler->>buildActPrompt: buildActPrompt(instruction, actions, variables)
buildActPrompt-->>ActHandler: "variables available: %password%"
ActHandler->>LLM: getActionFromLLM(instruction with variables)
LLM-->>ActHandler: {method: "fill", arguments: ["%password%"]}
ActHandler->>performUnderstudyMethod: perform action
performUnderstudyMethod-->>ActHandler: Error: Element not found
Note over ActHandler: Self-heal (BEFORE fix)
ActHandler->>buildActPrompt: buildActPrompt(actCommand, actions, {})
buildActPrompt-->>ActHandler: NO variable info ❌
LLM-->>ActHandler: Wrong/incomplete arguments
Note over ActHandler: Self-heal (AFTER fix)
ActHandler->>buildActPrompt: buildActPrompt(actCommand, actions, variables)
buildActPrompt-->>ActHandler: "variables available: %password%"
ActHandler->>LLM: getActionFromLLM(instruction with variables)
LLM-->>ActHandler: {method: "fill", arguments: ["%password%"]}
ActHandler->>performUnderstudyMethod: perform action with new selector
performUnderstudyMethod-->>ActHandler: Success ✓
ActHandler-->>User: {success: true}
|
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.
No issues found across 2 files
Fix: Self-Heal Loop Uses Empty Variables Object
Summary
Fixes the self-heal retry path in
actHandler.tsto passvariablesinstead of an empty object{}tobuildActPrompt. This ensures the LLM knows about available variable placeholders during self-heal attempts.Problem
In
actHandler.ts, when an action fails and self-heal is triggered, the retry call tobuildActPromptwas passing an empty object{}instead of thevariablesparameter that's available in scope:This contrasts with the first call (line 158-161) which correctly passes
variables.Impact
When a user calls:
First attempt:
{ method: "fill", arguments: ["%password%"] }Self-heal attempt (before fix):
{})%password%is validSelf-heal attempt (after fix):
{ method: "fill", arguments: ["%password%"] }Solution
Changed line 368 from
{}tovariables:Test Plan
self-heal-variables.test.ts(9 test cases)buildActPromptbehavior with variables vs empty objectFiles Changed
packages/core/lib/v3/handlers/actHandler.ts- Passvariablesinstead of{}in self-heal pathpackages/core/tests/self-heal-variables.test.ts- New regression test (9 test cases)Feedback? Email p0@kernel.dev
Summary by cubic
Fixes self-heal retries to pass the variables object to buildActPrompt so prompts include available placeholders and retries use the correct values. Addresses BUG-024.
Written for commit 8fa297c. Summary will update on new commits.