feat(langchain): add Stagehand code-mode MCP example - #2629
Conversation
|
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
There was a problem hiding this comment.
All reported issues were addressed
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
…into shrey/stg-2765-codemode-langchain
…into shrey/stg-2765-codemode-langchain
…into shrey/stg-2765-codemode-langchain # Conflicts: # .github/workflows/codemode-framework-examples.yml # packages/integrations/README.md
There was a problem hiding this comment.
1 issue found across 8 files (changes from recent commits).
Confidence score: 5/5
- In
packages/integrations/examples/langchain/agent.py, the newbuild_stagehand_agent,run_stagehand_agent, andstagehand_code_sessionpaths are not covered by focused unit tests, so behavior regressions in agent construction or session scoping could slip through unnoticed; add targeted tests for these flows (including success and failure/session-boundary cases) to de-risk future changes.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/integrations/examples/langchain/agent.py">
<violation number="1" location="packages/integrations/examples/langchain/agent.py:63">
P3: The newly added agent-construction and session-scoping paths (`build_stagehand_agent`, `run_stagehand_agent`, `stagehand_code_session`) have no focused unit tests — the existing tests cover only the client shape, tool-description validation, and the tool-call counter. These paths are currently validated only through the live, model-dependent e2e. Adding focused tests that verify `build_stagehand_agent` passes the tool description as the system prompt, rejects non-`code_execute` tools, and that `stagehand_code_session` scopes the loaded tool to one session would encode the contract and protect against regressions independently of the flaky real-model run.</violation>
</file>
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
| yield await load_stagehand_code_tool(session) | ||
|
|
||
|
|
||
| def build_stagehand_agent( |
There was a problem hiding this comment.
P3: The newly added agent-construction and session-scoping paths (build_stagehand_agent, run_stagehand_agent, stagehand_code_session) have no focused unit tests — the existing tests cover only the client shape, tool-description validation, and the tool-call counter. These paths are currently validated only through the live, model-dependent e2e. Adding focused tests that verify build_stagehand_agent passes the tool description as the system prompt, rejects non-code_execute tools, and that stagehand_code_session scopes the loaded tool to one session would encode the contract and protect against regressions independently of the flaky real-model run.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/integrations/examples/langchain/agent.py, line 63:
<comment>The newly added agent-construction and session-scoping paths (`build_stagehand_agent`, `run_stagehand_agent`, `stagehand_code_session`) have no focused unit tests — the existing tests cover only the client shape, tool-description validation, and the tool-call counter. These paths are currently validated only through the live, model-dependent e2e. Adding focused tests that verify `build_stagehand_agent` passes the tool description as the system prompt, rejects non-`code_execute` tools, and that `stagehand_code_session` scopes the loaded tool to one session would encode the contract and protect against regressions independently of the flaky real-model run.</comment>
<file context>
@@ -3,120 +3,105 @@
+ yield await load_stagehand_code_tool(session)
+
+
+def build_stagehand_agent(
+ code_tool: BaseTool,
+ model: str | Any = DEFAULT_STAGEHAND_MODEL,
</file context>
There was a problem hiding this comment.
Addressed in c29ce4a8. The focused suite now verifies canonical tool-description → system-prompt wiring, rejects non-code_execute tools without reflecting remote names, proves one named MCP session owns the loaded tool, and exercises run_stagehand_agent input/config wiring. The exact pinned environment passes 9/9 agent/session tests.
There was a problem hiding this comment.
All reported issues were addressed across 1 file (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
There was a problem hiding this comment.
All reported issues were addressed across 7 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
Why
Stagehand code mode executes model-generated JavaScript. This integration keeps that execution behind the package-installed Vercel Sandbox boundary from #2626 while preserving the explicit stateful MCP session LangChain requires.
Stack
@browserbasehq/stagehand-codemodepackage and CLIWhat changed
MultiServerMCPClientover authenticated Streamable HTTP{ url, token }connectionclient.session("stagehand")across discovery, direct calls, and the complete Deep Agent invocation; the default convenience path is intentionally not used because it is statelesscode_executedescription and uses it as the Deep Agent system prompt instead of copying the schema, executor, or skillProof matrix
sandboxandagentimports resolve.pnpm checkopenai:gpt-5-minimodel-selected call, independent DOM verification, credential isolation, and ordered cleanup before emittingPASS.The live job intentionally fails closed when repository Browserbase, Vercel, or OpenAI credentials are absent. Repository Vercel credentials are not currently configured for this workflow, so no live pass is claimed yet.
Changeset
None. This adds an integration example and CI proof surface without changing a published API.