Merged
Conversation
This commit adds tests that verify: - act() logs at level 0 when LLM returns element ID with no xpath - act() returns success: false when xpath lookup fails - observe() logs at level 0 and filters out actions when xpath lookup fails - observe() handles multiple elements with missing xpaths correctly The tests currently fail because the logging is not yet implemented. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
When the LLM returns an element ID that doesn't exist in the xpath map, we now log a clear level 0 message: "LLM returned ID x, there is no xpath keyed by this ID" Changes: - actHandler.ts: Added logging in normalizeActInferenceElement when xpath lookup fails, returning success: false - observeHandler.ts: Added logging when element ID has no xpath, filtering out those actions from the response This improves debuggability when the LLM returns invalid element IDs. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 80b6b94 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 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
Greptile OverviewGreptile SummaryAdded level 0 (ERROR) logging when the LLM returns element IDs that have no corresponding xpath in the lookup map. Changes
ImpactImproves observability for debugging LLM inference issues by explicitly logging when the LLM returns invalid element IDs. The error logging will help identify when the accessibility tree snapshot and LLM response are misaligned. Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Client
participant ActHandler
participant LLM
participant XPathMap
participant Logger
Client->>ActHandler: act(instruction)
ActHandler->>ActHandler: captureHybridSnapshot()
ActHandler->>LLM: getActionFromLLM(instruction, domElements)
LLM-->>ActHandler: element with ID "1-999"
ActHandler->>ActHandler: normalizeActInferenceElement()
ActHandler->>XPathMap: lookup elementId "1-999"
XPathMap-->>ActHandler: undefined (not found)
ActHandler->>Logger: v3Logger(level: 0, message: "LLM returned ID...")
Logger-->>ActHandler: logged
ActHandler->>ActHandler: return undefined (no action)
ActHandler-->>Client: { success: false, message: "No action found" }
Note over Client,Logger: Same flow applies to ObserveHandler<br/>but filters out invalid elements instead
|
Contributor
There was a problem hiding this comment.
No issues found across 3 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Architecture diagram
sequenceDiagram
participant User
participant Act as ActHandler
participant Obs as ObserveHandler
participant Snap as Snapshot Utility
participant LLM as Inference (LLM)
participant Log as v3Logger
Note over User, Log: Act Flow: Handling Invalid Element IDs
User->>Act: act(instruction)
Act->>Snap: captureHybridSnapshot()
Snap-->>Act: { combinedXpathMap, combinedTree }
Act->>LLM: act(instruction, combinedTree)
LLM-->>Act: { elementId: "1-999", method: "click" }
Act->>Act: Lookup "1-999" in combinedXpathMap
alt NEW: elementId not in map
Act->>Log: NEW: log(level: 0, category: "action")
Note right of Log: "no xpath keyed by this ID"
Act-->>User: CHANGED: { success: false, message: "No action found" }
else Valid elementId
Act->>Act: Perform browser action
Act-->>User: { success: true }
end
Note over User, Log: Observe Flow: Filtering Invalid Elements
User->>Obs: observe(instruction)
Obs->>Snap: captureHybridSnapshot()
Snap-->>Obs: { combinedXpathMap }
Obs->>LLM: observe(instruction)
LLM-->>Obs: Array of elements [{ id: "1-0" }, { id: "1-999" }]
loop For each element returned by LLM
Obs->>Obs: Lookup ID in combinedXpathMap
alt NEW: ID "1-999" missing from map
Obs->>Log: NEW: log(level: 0, category: "observation")
Note right of Obs: Filter out element from final list
else ID "1-0" exists
Note right of Obs: Include element in results
end
end
Obs-->>User: Return filtered elements array
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.
why
what changed
test plan
Summary by cubic
Add level-0 logging when the LLM returns an element ID with no matching xpath and handle these cases gracefully in act and observe. Implements STG-1209 to improve debuggability and prevent invalid element IDs from propagating.
Written for commit 80b6b94. Summary will update on new commits. Review in cubic