Skip to content

Conversation

@shivammittal274
Copy link
Contributor

@shivammittal274 shivammittal274 commented Nov 26, 2025

Removed unnecessary code of claude agent, formatters etc

Refactoring of vercel ai sdk with unncessary changes

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Nov 26, 2025

Greptile Overview

Greptile Summary

This PR removes Claude and Codex agent implementations along with the agent factory pattern, consolidating on a single GeminiAgent implementation. The refactoring simplifies the codebase by removing ~2,500 lines of code.

Key Changes:

  • Removed BaseAgent, ClaudeSDKAgent, CodexSDKAgent, and associated formatters/configs
  • Removed AgentFactory and registry pattern in favor of direct GeminiAgent instantiation
  • Simplified VercelAIContentGenerator from multi-provider registry to single provider per instance
  • Updated streaming format from custom v5 SSE to AI SDK standard format
  • Added BROWSEROS provider support

Critical Issues:

  • packages/agent/src/index.ts exports deleted classes (AgentFactory, BaseAgent, registerAgents) causing build failures
  • SessionManager.ts imports and uses deleted AgentFactory and BaseAgent classes, breaking runtime functionality
  • Debug console.log left in GeminiAgent.ts:98

The architectural simplification is sound, but the PR is incomplete - existing code still references deleted classes, making this a breaking change that will prevent the application from building or running.

Confidence Score: 0/5

  • This PR cannot be merged - it breaks module compilation and runtime functionality
  • Score of 0 reflects critical build-breaking bugs: the main package export file references deleted classes causing compilation errors, and SessionManager still uses the deleted AgentFactory pattern. These are not minor issues but fundamental breaks that prevent the code from building or running.
  • Critical attention required for packages/agent/src/index.ts and packages/agent/src/session/SessionManager.ts - both reference deleted code and must be updated before this PR can be merged

Important Files Changed

File Analysis

Filename Score Overview
packages/agent/src/index.ts 0/5 Exports deleted classes causing build failure - critical breaking change
packages/agent/src/agent/GeminiAgent.ts 4/5 New Gemini agent implementation added, debug console.log needs removal
packages/agent/src/agent/types.ts 5/5 Simplified to only AgentConfig schema, removed extensive type definitions
packages/agent/src/agent/gemini-vercel-sdk-adapter/index.ts 5/5 Refactored from multi-provider registry to single provider per instance
packages/agent/src/session/SessionManager.ts 0/5 References deleted AgentFactory and BaseAgent - will break at runtime

Sequence Diagram

sequenceDiagram
    participant Client as Client/Frontend
    participant Agent as GeminiAgent
    participant ContentGen as VercelAIContentGenerator
    participant Provider as AI Provider (Anthropic/OpenAI/Google/etc)
    participant MCP as MCP Server (BrowserOS)
    participant GeminiClient as GeminiClient (from gemini-cli-core)

    Client->>Agent: create(config)
    activate Agent
    Agent->>Agent: Resolve config (BROWSEROS provider if needed)
    Agent->>ContentGen: new VercelAIContentGenerator(config)
    Agent->>GeminiClient: Initialize with ContentGenerator
    Agent->>MCP: Connect to MCP server (if configured)
    Agent-->>Client: GeminiAgent instance
    deactivate Agent

    Client->>Agent: execute(message, honoStream, signal)
    activate Agent
    Agent->>ContentGen: setHonoStream(honoStream)
    
    loop Max 100 turns
        Agent->>GeminiClient: sendMessageStream(parts, signal)
        activate GeminiClient
        
        GeminiClient->>ContentGen: generateContentStream(request)
        activate ContentGen
        ContentGen->>Provider: streamText(model, messages, tools)
        
        loop Stream chunks
            Provider-->>ContentGen: text/tool-call chunks
            ContentGen->>ContentGen: Convert to Gemini format
            ContentGen->>Client: Write to honoStream (AI SDK format)
        end
        
        ContentGen-->>GeminiClient: GenerateContentResponse
        deactivate ContentGen
        
        alt Has tool calls
            GeminiClient-->>Agent: ToolCallRequest events
            deactivate GeminiClient
            
            loop Each tool call
                Agent->>GeminiClient: executeToolCall(config, requestInfo)
                activate GeminiClient
                GeminiClient->>MCP: Execute tool
                MCP-->>GeminiClient: Tool result
                GeminiClient-->>Agent: Tool response parts
                deactivate GeminiClient
            end
            
            Note over Agent: Continue loop with tool results
        else No tool calls
            Note over Agent: Break loop - execution complete
        end
    end
    
    Agent-->>Client: Execution complete
    deactivate Agent
Loading

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.

Additional Comments (2)

  1. packages/agent/src/index.ts, line 13-16 (link)

    syntax: Exports reference deleted files - breaks module compilation

    The AgentFactory, registerAgents, and BaseAgent exports reference files that were deleted in this PR, causing build errors.

  2. packages/agent/src/session/SessionManager.ts, line 10-16 (link)

    syntax: SessionManager imports deleted classes but doesn't use new GeminiAgent

    The imports reference AgentFactory and BaseAgent which were deleted. This file needs updates to work with the new GeminiAgent implementation.

19 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

Copy link
Contributor

@felarof99 felarof99 left a comment

Choose a reason for hiding this comment

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

Looks good, some minor fixes.

@felarof99
Copy link
Contributor

LGTM

@felarof99 felarof99 merged commit 6fe4b79 into main Nov 26, 2025
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.

3 participants