Add executionModel serialization to api client#1636
Conversation
🦋 Changeset detectedLatest commit: 0372c38 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 |
✱ Stainless preview buildsThis PR will update the ⚡ stagehand-go studio · conflict
⚡ stagehand-python studio · conflict
|
Greptile OverviewGreptile SummarySerializes and sends Changes made:
The implementation correctly mirrors the existing Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Client as Client Code
participant V3 as V3 Instance
participant AgentHandler as V3AgentHandler
participant APIClient as StagehandAPIClient
participant AgentTools as Agent Tools
participant API as Stagehand API
Note over Client,API: Agent Execution with executionModel
Client->>V3: agent({ executionModel: "openai/gpt-4o-mini" })
V3->>V3: resolveLlmClient(executionModel)
V3->>AgentHandler: new V3AgentHandler(v3, llmClient, executionModel, ...)
AgentHandler->>AgentTools: createAgentTools(v3, { executionModel })
Note over AgentTools: Tools (act, extract, fillForm)<br/>now use executionModel
Client->>V3: execute(instruction, agentConfig)
V3->>APIClient: agentExecute(executeOptions, agentConfig)
Note over APIClient: NEW: Serialize executionModel
APIClient->>APIClient: prepareModelConfig(agentConfig.executionModel)
Note over APIClient: Converts to wire format:<br/>{ modelName, apiKey }
APIClient->>API: POST /sessions/{id}/agentExecute
Note over API: agentConfig: {<br/> model: {...},<br/> executionModel: {...}<br/>}
API->>API: Execute agent with tool execution model
Note over API: Tools use executionModel<br/>for observe/act calls
API-->>APIClient: AgentResult
APIClient-->>V3: AgentResult
V3-->>Client: AgentResult
|
There was a problem hiding this comment.
1 issue found across 4 files
Confidence score: 3/5
- Moderate risk: a breaking-change area in the Stagehand REST API client/server is touched without the required integration test, which could allow regressions to slip in.
- Missing integration coverage for
executionModelserialization means potential client/server mismatch could go unnoticed. - Pay close attention to
packages/core/lib/v3/api.ts- missing integration test for executionModel serialization.
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="packages/core/lib/v3/api.ts">
<violation number="1" location="packages/core/lib/v3/api.ts:370">
P2: Rule violated: **Any breaking changes to Stagehand REST API client / server implementation must be covered by an integration test under packages/server/test**
Missing integration test for `executionModel` serialization. Rule requires that breaking changes to the REST API client must be covered by integration tests under `packages/server/test`. The existing `agentExecute.test.ts` tests other `agentConfig` fields but does not test `executionModel`. Please add a test case that verifies `executionModel` is correctly serialized and handled by the server.</violation>
</file>
Architecture diagram
sequenceDiagram
participant App as Application Logic
participant Client as StagehandAPIClient
participant Utils as prepareModelConfig
participant API as Backend API
participant Tools as Agent Tooling
Note over App,Tools: Flow: Initializing and Propagating Agent Configuration
App->>Client: createAgent(agentConfig)
rect rgb(240, 240, 240)
Note right of Client: Request Preparation
Client->>Utils: prepareModelConfig(agentConfig.model)
Utils-->>Client: ModelConfig (wire format)
opt NEW: executionModel is present
Client->>Utils: NEW: prepareModelConfig(agentConfig.executionModel)
Utils-->>Client: ModelConfig (wire format)
end
end
Client->>API: POST /v3/agent/sessions (with serialized AgentConfig)
Note over API: CHANGED: Validates body via AgentConfigSchema<br/>(Includes new executionModel field)
alt Success
API-->>Client: 201 Created
Client-->>App: Agent Instance
else Validation Error
API-->>Client: 400 Bad Request
end
Note over API,Tools: Runtime Execution
API->>Tools: Initialize tools with AgentConfig
opt Tools Perform Actions (Observe/Act)
alt executionModel provided
Tools->>Tools: Use executionModel for LLM calls
else executionModel missing
Tools->>Tools: Fallback: Use main model config
end
end
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
|
@miguelg719 I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
No issues found across 5 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Architecture diagram
sequenceDiagram
participant SDK as SDK / User
participant Client as StagehandAPIClient
participant Server as API Server (v1/sessions)
participant Agent as Agent Executor
Note over SDK, Agent: Agent Execution Flow with Model Specialization
SDK->>Client: agentExecute(options)
Client->>Client: prepareModelConfig(agentConfig.model)
alt NEW: executionModel provided
Client->>Client: NEW: prepareModelConfig(agentConfig.executionModel)
else executionModel missing
Note over Client: Defaults to main model configuration
end
Client->>Server: POST /agentExecute (JSON body)
Note right of Client: Includes serialized executionModel
Server->>Server: Validate against AgentConfigSchema
alt Validation Success
Server->>Agent: Initialize Execution
loop Tool Execution (Observe/Act)
Agent->>Agent: NEW: Use executionModel for tool logic
Note over Agent: Uses specific model for sub-tasks if defined
end
Agent-->>Server: Execution Result
Server-->>SDK: 200 OK (Result)
else Validation Error
Server-->>SDK: 400 Bad Request
end
why
executionModelis not properly propagated to apiwhat changed
Serialize and send AgentConfig.executionModel to the API
test plan
Summary by cubic
Serialize and send AgentConfig.executionModel to the API, and document it in schemas so tool execution uses the intended model. Addresses Linear STG-1229 (execution model not reaching the API).
Written for commit 0372c38. Summary will update on new commits. Review in cubic