[chore]: strengthen regex validation on act, observe for elementId#1614
Merged
miguelg719 merged 2 commits intomainfrom Jan 27, 2026
Conversation
🦋 Changeset detectedLatest commit: 3b70cc1 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 |
elementId
Contributor
There was a problem hiding this comment.
No issues found across 2 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Architecture diagram
sequenceDiagram
participant Caller
participant Inference as inference.ts
participant Zod as Zod Schema
Note over Caller, Zod: Runtime Validation Flow for act() / observe()
Caller->>Inference: Invoke operation with params
Inference->>Zod: Define Schema
Note right of Zod: NEW: Added .regex(/^\d+-\d+$/)
Inference->>Zod: Validate input (elementId)
alt NEW: elementId format mismatch
Note right of Zod: Input like "[1-2]" or "123"<br/>fails regex check
Zod-->>Inference: Throw Validation Error
Inference-->>Caller: Error: Invalid elementId format
else Valid elementId
Note right of Zod: Input like "1-2" matches
Zod-->>Inference: Validation Success
Inference->>Inference: Execute Action logic
Inference-->>Caller: Result
end
Contributor
Greptile OverviewGreptile SummaryAdded regex validation (
Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Client
participant ObserveHandler
participant Zod Schema
participant LLM
participant ActHandler
Note over Client,ActHandler: Observe Flow
Client->>ObserveHandler: observe(instruction, domElements)
ObserveHandler->>Zod Schema: Define observeSchema with elementId.regex(/^\d+-\d+$/)
ObserveHandler->>LLM: createChatCompletion with schema
LLM-->>ObserveHandler: Return elements with elementId
Zod Schema->>Zod Schema: Validate elementId matches /^\d+-\d+$/
alt Valid format (e.g., "1-0")
Zod Schema-->>ObserveHandler: Validation passes
ObserveHandler-->>Client: Return parsed elements
else Invalid format (e.g., "[1-0]", "1", "a-b")
Zod Schema-->>ObserveHandler: Validation fails
ObserveHandler-->>Client: Throw validation error
end
Note over Client,ActHandler: Act Flow
Client->>ActHandler: act(instruction, domElements)
ActHandler->>Zod Schema: Define actSchema with elementId.regex(/^\d+-\d+$/)
ActHandler->>LLM: createChatCompletion with schema
LLM-->>ActHandler: Return element with elementId
Zod Schema->>Zod Schema: Validate elementId matches /^\d+-\d+$/
alt Valid format (e.g., "1-0")
Zod Schema-->>ActHandler: Validation passes
ActHandler-->>Client: Return parsed element
else Invalid format (e.g., "[1-0]", "1", "a-b")
Zod Schema-->>ActHandler: Validation fails
ActHandler-->>Client: Throw validation error
end
|
elementIdact, observe for elementId
seanmcguire12
approved these changes
Jan 27, 2026
This was referenced Jan 27, 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.
why
Stricter validation on LLM responses for chosen elementId to interact with
what changed
V3 includes only elementIds in the shape
number-numberto account for iframe ordinals. This PR ensures the LLMs have stricter validation on the elementId generation by changing the observe and act schemas to to enforcetest plan
Summary by cubic
Enforce 'number-number' format for elementId in observe and act via regex (^\d+-\d+$) to prevent invalid IDs. Aligns with Linear STG-675 guardrail requirements for elementId formatting.
Written for commit 3b70cc1. Summary will update on new commits. Review in cubic