Skip to content

Conversation

@hairuchen
Copy link

@hairuchen hairuchen commented Dec 22, 2025

Why

The original version does not support Alibaba Qwen model calls and flexible configuration of local browser executable paths.

What Changed

  1. Adapted Alibaba Qwen model (added compatibility for non-pydantic scenarios).
  2. Added executable_path configuration item to allow developers to specify local browser engines.

Test Plan

  • Tested Qwen model invocation in LOCAL mode (function normally).
  • Verified executable_path takes effect when specified, and uses default browser path when not specified.

Summary by cubic

Adds Alibaba Qwen model support in LOCAL mode and a new executable_path option to choose a local browser binary. This enables qwen-turbo/plus/max with JSON-safe responses and keeps metrics working.

  • New Features
    • Added QwenClient (DashScope chat/completions) and auto-select it for qwen-turbo, qwen-plus, qwen-max.
    • Supports response_format via json_schema/json_object; injects a system prompt to enforce strict JSON; normalizes elements[].arguments to a list.
    • Wrapped responses in a HybridDict to allow attribute-style access and preserve metrics callback behavior.
    • Added executable_path in local browser launch options; uses the provided path when set, otherwise defaults.

Written for commit 036ed18. Summary will update automatically on new commits.

2.添加了executable_path的配置项,用于提供给开发者选用本地浏览器引擎
Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 4 files

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="stagehand/main.py">

<violation number="1" location="stagehand/main.py:33">
P0: Import path mismatch: the file is `qwenclient.py` (no underscore), but the import references `qwen_client`. This will cause an `ImportError` at runtime.</violation>
</file>

<file name="stagehand/llm/qwenclient.py">

<violation number="1" location="stagehand/llm/qwenclient.py:38">
P1: Constructor passes `model_api_key` but parent `LLMClient.__init__` expects `api_key`. This will cause the API key to be passed through `**kwargs` instead of the correct parameter, potentially breaking parent class initialization.</violation>
</file>

Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Ask questions if you need clarification on any suggestion

Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR

from .metrics import StagehandFunctionName, StagehandMetrics
from .page import StagehandPage
from .utils import get_download_path, make_serializable
from stagehand.llm.qwen_client import QwenClient # 导入千问客户端
Copy link

@cubic-dev-ai cubic-dev-ai bot Dec 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P0: Import path mismatch: the file is qwenclient.py (no underscore), but the import references qwen_client. This will cause an ImportError at runtime.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At stagehand/main.py, line 33:

<comment>Import path mismatch: the file is `qwenclient.py` (no underscore), but the import references `qwen_client`. This will cause an `ImportError` at runtime.</comment>

<file context>
@@ -30,6 +30,7 @@
 from .metrics import StagehandFunctionName, StagehandMetrics
 from .page import StagehandPage
 from .utils import get_download_path, make_serializable
+from stagehand.llm.qwen_client import QwenClient  # 导入千问客户端
 
 load_dotenv()
</file context>

✅ Addressed in 6ac0808

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 2 files (changes from recent commits).

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="stagehand/llm/qwenclient.py">

<violation number="1" location="stagehand/llm/qwenclient.py:41">
P0: This change renames the instance variable from `self.model_api_key` to `self.api_key`, but line 60 still references `self.model_api_key` in the Authorization header. This will cause an `AttributeError` at runtime when making API calls. The header construction needs to be updated to use `self.api_key`.</violation>
</file>

<file name="stagehand/main.py">

<violation number="1" location="stagehand/main.py:292">
P0: `self.api_key` is not defined in the `Stagehand` class. This will raise an `AttributeError` at runtime. The correct attribute is `self.model_api_key`, which is used for the `LLMClient` below.</violation>
</file>

Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant