Skip to content

feat: BrowserUse Scenario Support#300

Open
JagjeevanAK wants to merge 8 commits intovolcano-sh:mainfrom
JagjeevanAK:jagjeevan/broweruse
Open

feat: BrowserUse Scenario Support#300
JagjeevanAK wants to merge 8 commits intovolcano-sh:mainfrom
JagjeevanAK:jagjeevan/broweruse

Conversation

@JagjeevanAK
Copy link
Copy Markdown

What type of PR is this?

/kind feature

What this PR does / why we need it:
This PR introduces support for the BrowserUse scenario within the AgentCube platform as a first-class citizen, mirroring the AgentRuntime and CodeInterpreter patterns. It provides a purpose-built declarative API for browser automation workloads.

Changes:

  • Defined a new BrowserUse CRD type.
  • Updated Workload Manager to handle BrowserUse lifecycle events (informer, builder, server/handlers).
  • Integrated the Router for proxying BrowserUse invocation requests.
  • Implemented browser-use specific routing in SessionManager.
  • Included an RFC-style proposal document in docs/design.

Which issue(s) this PR fixes:
Fixes #26

Special notes for your reviewer:

  • Includes a pre-existing test fix for informers_test.go to prevent panics due to the new informer being uninitialized in tests.

Does this PR introduce a user-facing change?:

Introduced a new `BrowserUse` Custom Resource Definition (CRD) to support browser automation environments alongside AgentRuntime and CodeInterpreter.

Signed-off-by: Jagjeevan Kashid <jagjeevandev97@gmail.com>
Copilot AI review requested due to automatic review settings April 28, 2026 03:46
@volcano-sh-bot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign hzxuzhonghu for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds first-class BrowserUse scenario support to AgentCube, extending the existing AgentRuntime/CodeInterpreter end-to-end flow (CRD → Workload Manager provisioning → Router invocation proxying).

Changes:

  • Introduces BrowserUse CRD types (plus generated deepcopy + registration metadata) and an example manifest.
  • Extends Workload Manager informers/routes/handlers and workload builder to create sandboxes from BrowserUse templates.
  • Extends Router routes/handlers/session-manager to proxy BrowserUse invocations and create BrowserUse sandboxes via Workload Manager.

Reviewed changes

Copilot reviewed 16 out of 17 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
pkg/workloadmanager/workload_builder.go Adds sandbox build path for BrowserUse resources.
pkg/workloadmanager/server.go Adds WM management routes for BrowserUse create/delete.
pkg/workloadmanager/informers.go Adds BrowserUse informer + cache sync gating.
pkg/workloadmanager/informers_test.go Updates informer sync tests to include BrowserUse.
pkg/workloadmanager/handlers.go Adds BrowserUse create handler and kind switch branch.
pkg/router/session_manager.go Adds BrowserUse → WM endpoint mapping for sandbox creation.
pkg/router/server.go Adds BrowserUse invocation routes.
pkg/router/handlers.go Adds BrowserUse invocation handler wired into common invoke path.
pkg/common/types/types.go Adds BrowserUseKind constant.
pkg/common/types/sandbox.go Allows BrowserUseKind in CreateSandboxRequest validation.
pkg/api/errors.go Adds BrowserUse “not found” error and resource mapping.
pkg/apis/runtime/v1alpha1/browseruse_types.go New BrowserUse CRD Go types.
pkg/apis/runtime/v1alpha1/register.go Adds BrowserUse GVK metadata.
pkg/apis/runtime/v1alpha1/zz_generated.deepcopy.go Generated deepcopy for BrowserUse types.
example/browser-agent/browseruse.yaml Example BrowserUse custom resource.
docs/design/browseruse-proposal.md RFC-style design/proposal documentation for BrowserUse.

Comment thread pkg/workloadmanager/workload_builder.go Outdated
Comment on lines +56 to +59
// handleBrowserUseCreate handles BrowserUse sandbox creation requests.
func (s *Server) handleBrowserUseCreate(c *gin.Context) {
s.handleSandboxCreate(c, types.BrowserUseKind)
}
Copy link

Copilot AI Apr 28, 2026

Choose a reason for hiding this comment

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

There’s no unit test coverage for the new BrowserUse create path. TestHandleSandboxCreate currently covers AgentRuntime and CodeInterpreter, but doesn’t exercise handleBrowserUseCreate / the types.BrowserUseKind branch, so regressions in this new endpoint won’t be caught.

Copilot generated this review using guidance from repository custom instructions.
Comment thread pkg/router/handlers.go
Comment on lines +324 to +330
// handleBrowserUseInvoke handles browser use invocation requests
func (s *Server) handleBrowserUseInvoke(c *gin.Context) {
namespace := c.Param("namespace")
name := c.Param("name")
path := c.Param("path")
s.handleInvoke(c, namespace, name, path, types.BrowserUseKind)
}
Copy link

Copilot AI Apr 28, 2026

Choose a reason for hiding this comment

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

No router handler test exercises the new BrowserUse invocation route/handler. handlers_test.go has coverage for AgentRuntime and CodeInterpreter invocations, but nothing for /browser-uses/.../invocations/*path, so this new path could break without failing tests.

Copilot generated this review using guidance from repository custom instructions.
Comment on lines 121 to +125
endpoint = m.workloadMgrAddr + "/v1/agent-runtime"
case types.CodeInterpreterKind:
endpoint = m.workloadMgrAddr + "/v1/code-interpreter"
case types.BrowserUseKind:
endpoint = m.workloadMgrAddr + "/v1/browser-use"
Copy link

Copilot AI Apr 28, 2026

Choose a reason for hiding this comment

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

createSandbox gained a new BrowserUseKind endpoint mapping, but session_manager_test.go doesn’t cover this case (it only verifies AgentRuntime and CodeInterpreter). Add a test asserting the request hits /v1/browser-use and marshals kind=BrowserUse.

Copilot generated this review using guidance from repository custom instructions.
Comment thread docs/design/browseruse-proposal.md Outdated
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 28, 2026

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 6.29371% with 134 lines in your changes missing coverage. Please review.
✅ Project coverage is 45.55%. Comparing base (57f6d84) to head (7c4be5b).
⚠️ Report is 70 commits behind head on main.

Files with missing lines Patch % Lines
pkg/apis/runtime/v1alpha1/zz_generated.deepcopy.go 0.00% 72 Missing ⚠️
pkg/workloadmanager/workload_builder.go 0.00% 44 Missing ⚠️
pkg/router/handlers.go 0.00% 5 Missing ⚠️
pkg/workloadmanager/handlers.go 20.00% 4 Missing ⚠️
pkg/api/errors.go 0.00% 2 Missing ⚠️
pkg/router/session_manager.go 0.00% 2 Missing ⚠️
pkg/workloadmanager/informers.go 66.66% 2 Missing ⚠️
pkg/workloadmanager/server.go 0.00% 2 Missing ⚠️
pkg/common/types/sandbox.go 0.00% 1 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #300      +/-   ##
==========================================
+ Coverage   43.37%   45.55%   +2.18%     
==========================================
  Files          30       31       +1     
  Lines        2610     2961     +351     
==========================================
+ Hits         1132     1349     +217     
- Misses       1355     1472     +117     
- Partials      123      140      +17     
Flag Coverage Δ
unittests 45.55% <6.29%> (+2.18%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the BrowserUse CRD to AgentCube for browser automation workloads, including updates to the workload manager, router, and session management. Feedback focuses on improving robustness by adding a nil check for the pod template and handling ignored errors in the workload builder. Additionally, there are suggestions to standardize the targetPort field name to ports for API consistency and to fix a local file link in the design document.

Comment thread pkg/workloadmanager/workload_builder.go
Comment thread docs/design/browseruse-proposal.md Outdated
Comment thread docs/design/browseruse-proposal.md Outdated
name: playwright-mcp
namespace: default
spec:
targetPort:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The field name in the example YAML should be updated to ports for consistency with Kubernetes naming conventions for collections.

Suggested change
targetPort:
ports:

name: playwright-mcp
namespace: default
spec:
targetPort:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The field name targetPort should be updated to ports to match the suggested change in the CRD definition for consistency.

  ports:

// Ports is a list of ports that the browser runtime will expose.
// Typically includes the browser automation protocol port (e.g., Playwright MCP on 8931)
// and optionally a VNC port for visual debugging.
Ports []TargetPort `json:"targetPort"`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The field Ports is a slice, but its JSON tag is targetPort (singular). Following Kubernetes and Go conventions, plural fields should typically have plural JSON tags (e.g., ports or targetPorts) to improve API clarity and consistency.

Suggested change
Ports []TargetPort `json:"targetPort"`
Ports []TargetPort `json:"ports"`

Comment thread pkg/workloadmanager/workload_builder.go Outdated
Run make gen-client to generate typed clients, listers, and informers
for the new BrowserUse CRD. Also fix update-codegen.sh to patch the
GroupResource() call for browseruse in the generated lister (same fix
applied to agentruntime and codeinterpreter).

Signed-off-by: Jagjeevan Kashid <jagjeevandev97@gmail.com>
The BrowserUseInformer requires list/watch permissions on the
browseruses resource. Without this, the workload manager pod cannot
start (WaitForCacheSync times out causing Helm --wait to fail in e2e).

Signed-off-by: Jagjeevan Kashid <jagjeevandev97@gmail.com>
Copilot AI review requested due to automatic review settings April 28, 2026 04:14
JagjeevanAK and others added 2 commits April 28, 2026 09:44
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Jagjeevan Kashid <jagjeevankashid97@gmail.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Signed-off-by: Jagjeevan Kashid <jagjeevankashid97@gmail.com>
JagjeevanAK and others added 2 commits April 28, 2026 09:46
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Jagjeevan Kashid <jagjeevankashid97@gmail.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Signed-off-by: Jagjeevan Kashid <jagjeevankashid97@gmail.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 28 out of 29 changed files in this pull request and generated 2 comments.

Comment on lines +442 to +447
browserUseKey := namespace + "/" + name
// TODO(hzxuzhonghu): make use of typed informer, so we don't need to do type conversion below
runtimeObj, exists, err := ifm.BrowserUseInformer.GetStore().GetByKey(browserUseKey)
if err != nil {
return nil, nil, fmt.Errorf("failed to get browser use %s from informer store: %w", browserUseKey, err)
}
Copy link

Copilot AI Apr 28, 2026

Choose a reason for hiding this comment

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

GetByKey can return a non-nil error; currently it is ignored (_). This can mask informer/cache failures as a "not found" and make troubleshooting harder. Handle and return the error (wrapping it) before checking exists (similar to buildSandboxByCodeInterpreter).

Copilot uses AI. Check for mistakes.

#### Why a Separate CRD?

The rationale mirrors the original decision to separate `CodeInterpreter` from `AgentRuntime` (see [runtime-template-proposal.md](./runtime-template-proposal.md)):
Copy link

Copilot AI Apr 28, 2026

Choose a reason for hiding this comment

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

This document links to a local file:///Users/... path, which will be broken for anyone else reading the repo. Replace it with a repo-relative link (e.g., docs/design/runtime-template-proposal.md) or a URL that is valid in GitHub.

Copilot uses AI. Check for mistakes.
@JagjeevanAK
Copy link
Copy Markdown
Author

This PR is ready from my end, and it will serve as a good starting point for the initial version launch of this feature.

CC: @YaoZengzeng, @acsoto, @tizhou86

Comment thread example/browser-agent/browseruse.yaml Outdated
Signed-off-by: Jagjeevan Kashid <jagjeevandev97@gmail.com>
@volcano-sh-bot
Copy link
Copy Markdown
Contributor

Keywords which can automatically close issues and at(@) or hashtag(#) mentions are not allowed in commit messages.

The list of commits with invalid commit messages:

  • e20a187 Update docs/design/browseruse-proposal.md
  • 126da3d Update pkg/workloadmanager/workload_builder.go
Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add broweruse scenario suppport

5 participants