-
Notifications
You must be signed in to change notification settings - Fork 1.3k
patch agent on api #1336
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
patch agent on api #1336
Conversation
🦋 Changeset detectedLatest commit: 8980e9f The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 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 |
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 1 file
Greptile OverviewGreptile SummaryThis PR fixes a defensive programming issue in the V3 agent execution path. When the Important Files Changed
Confidence score: 5/5
Sequence DiagramsequenceDiagram
participant User
participant V3
participant AgentCache
participant StagehandAPIClient
participant V3AgentHandler
participant V3CuaAgentHandler
User->>V3: "agent(options).execute(instructionOrOptions)"
alt "CUA mode enabled (options?.cua)"
V3->>V3: "validateCUARequirements()"
V3->>AgentCache: "buildConfigSignature(options)"
V3->>V3: "normalizeToV3Page(resolvedOptions.page)"
V3->>AgentCache: "shouldAttemptCache(instruction)"
alt "cache enabled"
V3->>AgentCache: "prepareContext()"
AgentCache->>AgentCache: "tryReplay(cacheContext)"
alt "cache hit"
AgentCache-->>V3: "cached result"
V3-->>User: "AgentResult"
end
end
alt "API client enabled and not experimental"
V3->>StagehandAPIClient: "agentExecute(options ?? {}, resolvedOptions, frameId)"
StagehandAPIClient-->>V3: "AgentResult"
else "local execution"
V3->>V3CuaAgentHandler: "new V3CuaAgentHandler()"
V3->>V3CuaAgentHandler: "execute(instructionOrOptions)"
V3CuaAgentHandler-->>V3: "AgentResult"
end
alt "recording enabled"
V3->>AgentCache: "store(cacheContext, agentSteps, result)"
end
V3-->>User: "AgentResult"
else "Standard mode with streaming (options?.stream)"
V3->>V3: "prepareAgentExecution()"
V3->>V3AgentHandler: "new V3AgentHandler()"
alt "cache enabled"
V3->>AgentCache: "tryReplayAsStream(cacheContext)"
alt "cache hit"
AgentCache-->>V3: "stream result"
V3-->>User: "AgentStreamResult"
end
end
V3->>V3AgentHandler: "stream(instructionOrOptions)"
V3AgentHandler-->>V3: "AgentStreamResult"
alt "caching enabled"
V3->>AgentCache: "wrapStreamForCaching()"
end
V3-->>User: "AgentStreamResult"
else "Standard mode without streaming"
V3->>V3: "prepareAgentExecution()"
V3->>V3AgentHandler: "new V3AgentHandler()"
alt "cache enabled"
V3->>AgentCache: "tryReplay(cacheContext)"
alt "cache hit"
AgentCache-->>V3: "cached result"
V3-->>User: "AgentResult"
end
end
alt "API client enabled and not experimental"
V3->>StagehandAPIClient: "agentExecute(options ?? {}, resolvedOptions, frameId)"
StagehandAPIClient-->>V3: "AgentResult"
else "local execution"
V3->>V3AgentHandler: "execute(instructionOrOptions)"
V3AgentHandler-->>V3: "AgentResult"
end
alt "recording enabled"
V3->>AgentCache: "store(cacheContext, agentSteps, result)"
end
V3-->>User: "AgentResult"
end
|
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.
1 file reviewed, no comments
why
if no options are provided, we need to provide an empty object
what changed
when options is empty, we fallback to empty object
test plan
tested locally
tested on api
Summary by cubic
Default options to {} for agentExecute calls in V3 to prevent errors when no options are provided. This makes API agent execution more resilient.
Why:
What:
Test Plan:
Written for commit 8980e9f. Summary will update automatically on new commits.