[Claimed #1978] fix: add variable substitution to keys step during cache replay#1983
Merged
[Claimed #1978] fix: add variable substitution to keys step during cache replay#1983
Conversation
Two fixes for %variableName% token handling in the keys tool: 1. Live execution: pass variables to keysTool, call substituteVariables() before page.type(), and update the schema description to advertise available variables to the LLM. Records the original token in the cache entry and returns it to the LLM to avoid exposing sensitive values. (Original fix by @trillville in #1777) 2. Cache replay: pass variables to replayAgentKeysStep in AgentCache and call substituteVariables() before page.type(). Without this, cached keys steps replay by typing literal %variableName% tokens instead of resolved values. Fixes #1776 Co-Authored-By: trillville <trillville@users.noreply.github.com> Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
Author
|
This mirrored PR has been merged into |
2 tasks
🦋 Changeset detectedLatest commit: abb3905 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
There was a problem hiding this comment.
No issues found across 4 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Architecture diagram
sequenceDiagram
participant Agent as Agent / LLM
participant Tool as keysTool
participant Util as substituteVariables
participant Cache as AgentCache
participant Browser as Browser Page
Note over Agent,Browser: Live Execution Flow
Agent->>Tool: execute(method: "type", value: "%password%")
rect rgb(240, 240, 240)
Note right of Tool: NEW: Resolve variables before typing
Tool->>Util: substituteVariables("%password%", variables)
Util-->>Tool: "secret_value_123"
end
Tool->>Browser: page.type("secret_value_123")
Note right of Tool: NEW: Record template value to cache (not secret)
Tool->>Cache: recordAgentReplayStep(text: "%password%")
Tool-->>Agent: { success: true, value: "%password%" }
Note over Agent,Browser: Cache Replay Flow (Subsequent Run)
Cache->>Cache: replayAgentKeysStep(step, variables)
alt step.method === "type"
rect rgb(240, 240, 240)
Note right of Cache: NEW: Substitute variables during replay
Cache->>Util: substituteVariables("%password%", variables)
Util-->>Cache: "secret_value_123"
end
Cache->>Browser: page.type("secret_value_123")
else method === "press"
Cache->>Browser: page.press(keys)
end
tkattkat
approved these changes
Apr 9, 2026
Member
|
thanks again @a7med3liamin! great addition |
This was referenced Apr 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Mirrored from external contributor PR #1978 after approval by @pirate.
Original author: @a7med3liamin
Original PR: #1978
Approved source head SHA:
2149aa265a04dc37154d5a84411f3ab4d1045897@a7med3liamin, please continue any follow-up discussion on this mirrored PR. When the external PR gets new commits, this same internal PR will be marked stale until the latest external commit is approved and refreshed here.
Original description
Fixes #1776
Problem
The
keystool has no variable substitution in either the live execution or cache replay paths. When the agent uses%variableName%tokens with the keys tool, the literal token string gets typed instead of the resolved value.Fix
This PR combines two fixes into one:
1. Live execution (original fix by @trillville from #1777)
variablesparameter inkeysTool(matchingtypeTool)substituteVariables()beforepage.type()in themethod === "type"branchvariablestokeysToolincreateAgentTools2. Cache replay (new fix)
substituteVariablesinAgentCache.tsvariablesthrough toreplayAgentKeysStepsubstituteVariables(text, variables)beforepage.type()in the replay pathWithout fix #2, cached
keyssteps withmethod="type"replay by typing literal%variableName%tokens even when variables are provided, sincereplayAgentKeysStephad no access to the variables map.Credit
The live execution fix (part 1) is from @trillville's work in #1777/#1813. We merged it here with the cache replay fix per @pirate's request to consolidate into a single PR.
Summary by cubic
Add variable substitution to the
keystool for both live execution and cache replay so%variableName%tokens are resolved before typing. This fixes cases where literal tokens were typed and brings parity with thetypetool.variablesintokeysand callsubstituteVariables()beforepage.type(); update the input schema to list available variables.variablestoreplayAgentKeysStepand substitute before typing to avoid replaying literal tokens.Written for commit abb3905. Summary will update on new commits. Review in cubic