Skip to content

Conversation

@shadowfax92
Copy link
Contributor

No description provided.

@shadowfax92 shadowfax92 merged commit ed75ba9 into main Oct 23, 2025
1 check passed
@github-actions github-actions bot locked and limited conversation to collaborators Oct 23, 2025
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Overview

Greptile Summary

This PR introduces a feature flag (WEBSOCKET_AGENT) to gate the WebSocket-based agent implementation that was added for BrowserOS provider support. The flag requires browser version 137.0.7220.69 or higher and is checked at runtime to determine whether to use WebSocketAgent/TeachWebSocketAgent or fall back to the standard LangChain-based agents (BrowserAgent/TeachAgent). The change modifies two files: the feature flag registry (featureFlags.ts) where the new flag is defined, and the execution orchestrator (Execution.ts) where the flag is checked at three decision points - teach mode initialization, browse mode initialization, and eval metrics reporting. This provides a kill-switch mechanism for the WebSocket agent feature, enabling safer rollout and quick rollback if needed without code deployment.

Important Files Changed

Filename Score Overview
src/lib/utils/featureFlags.ts 5/5 Adds WEBSOCKET_AGENT flag with version requirement 137.0.7220.69 following the established pattern
src/lib/execution/Execution.ts 3/5 Adds feature flag gates at three locations but duplicates the same provider type + flag check logic repeatedly

Confidence score:3.5/5

  • This PR introduces moderate risk due to code duplication and potential for logic drift across three identical feature checks
  • Score reflects good intent (feature flag for safe rollout) but implementation creates technical debt through repeated code blocks that check provider type and feature flag status in four separate locations (lines 214-219, 257-263, 337-340, 343-348)
  • Pay close attention to src/lib/execution/Execution.ts where the duplicated feature check logic creates maintenance burden and risk of inconsistent behavior if one check is updated but others are missed

Linked custom rules:

  • The repeated providerType + wsAgentEnabled check violates the rule to "Favor loops and small helper modules over duplicate code" and should be extracted into a single reusable method
  • The PR appears to follow the pattern established by existing feature flags like TEACH_MODE and MCP_SERVER

Sequence Diagram

sequenceDiagram
    participant User
    participant Execution
    participant FeatureFlags
    participant BrowserOSAdapter
    participant LangChainProvider
    participant WebSocketAgent
    participant TeachWebSocketAgent
    participant LocalAgent
    participant BrowserAgent
    participant ChatAgent
    participant TeachAgent

    User->>Execution: run(query, metadata)
    Execution->>Execution: _ensureInitialized()
    Execution->>FeatureFlags: initialize()
    FeatureFlags->>BrowserOSAdapter: getVersion()
    BrowserOSAdapter-->>FeatureFlags: version string
    FeatureFlags-->>Execution: initialized
    
    Execution->>LangChainProvider: getModelCapabilities()
    LangChainProvider-->>Execution: capabilities (maxTokens, supportsImages)
    
    alt mode === "teach"
        Execution->>LangChainProvider: getCurrentProviderType()
        LangChainProvider-->>Execution: providerType
        Execution->>FeatureFlags: isEnabled('WEBSOCKET_AGENT')
        FeatureFlags-->>Execution: wsAgentEnabled
        
        alt providerType === 'browseros' && wsAgentEnabled
            Execution->>TeachWebSocketAgent: new TeachWebSocketAgent(context)
            Execution->>TeachWebSocketAgent: execute(query, teachMetadata)
            TeachWebSocketAgent-->>Execution: result
        else
            Execution->>TeachAgent: new TeachAgent(context)
            Execution->>TeachAgent: execute(workflow)
            TeachAgent-->>Execution: result
        end
        
    else mode === "chat"
        Execution->>ChatAgent: new ChatAgent(context)
        Execution->>ChatAgent: execute(query)
        ChatAgent-->>Execution: result
        
    else mode === "browse"
        Execution->>LangChainProvider: getCurrentProviderType()
        LangChainProvider-->>Execution: providerType
        Execution->>FeatureFlags: isEnabled('WEBSOCKET_AGENT')
        FeatureFlags-->>Execution: wsAgentEnabled
        
        alt providerType === 'browseros' && wsAgentEnabled
            Execution->>WebSocketAgent: new WebSocketAgent(context)
            Execution->>WebSocketAgent: execute(query, metadata)
            WebSocketAgent-->>Execution: result
        else limitedContextMode || small model
            Execution->>LocalAgent: new LocalAgent(context)
            Execution->>LocalAgent: execute(query, metadata)
            LocalAgent-->>Execution: result
        else
            Execution->>BrowserAgent: new BrowserAgent(context)
            Execution->>BrowserAgent: execute(query, metadata)
            BrowserAgent-->>Execution: result
        end
    end
    
    Execution-->>User: execution complete
Loading

Context used (4)

  • Context from dashboard - .cursorrules (source)
  • Context from dashboard - CLAUDE.md (source)
  • Context from dashboard - .cursor/rules/cursorrules.mdc (source)
  • Context from dashboard - .cursor/rules/always.mdc (source)

2 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants