Skip to content

Conversation

@shivammittal274
Copy link
Contributor

No description provided.

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Nov 27, 2025

Greptile Overview

Greptile Summary

Added /batch endpoint to execute multiple act() commands sequentially from a single request, parsing them from the message body and streaming results with action markers.

  • Parses act("...") commands using regex and executes them sequentially
  • Reuses existing session management and streaming infrastructure from /chat endpoint
  • Includes abort signal handling to stop batch execution on client disconnect
  • Regex pattern doesn't handle escaped quotes within action strings (critical issue)

Confidence Score: 3/5

  • This PR has a critical regex bug that will fail on escaped quotes, but is otherwise well-structured
  • The implementation follows existing patterns and includes proper error handling, abort signal support, and logging. However, the regex pattern for parsing act() commands has a critical flaw that will fail when action strings contain escaped quotes like act("say \"hello\""), which is a common use case.
  • Pay close attention to packages/agent/src/http/HttpServer.ts line 147 - the regex pattern needs fixing before merge

Important Files Changed

File Analysis

Filename Score Overview
packages/agent/src/http/HttpServer.ts 4/5 Added /batch endpoint to execute multiple act() commands sequentially with streaming support

Sequence Diagram

sequenceDiagram
    participant Client
    participant HttpServer
    participant SessionManager
    participant GeminiAgent
    participant HonoStream

    Client->>HttpServer: POST /batch<br/>act("open amazon.com")\nact("open google.com")
    HttpServer->>HttpServer: Parse act() commands using regex
    HttpServer->>HttpServer: Extract actions array
    HttpServer->>SessionManager: getOrCreate(config)
    SessionManager-->>HttpServer: agent instance
    HttpServer->>HonoStream: Initialize streaming response
    
    loop For each action
        HttpServer->>HonoStream: Write action marker
        HttpServer->>GeminiAgent: execute(action, stream, signal)
        GeminiAgent->>HonoStream: Stream execution results
        GeminiAgent-->>HttpServer: Execution complete
    end
    
    HttpServer->>Client: Complete streaming response
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.

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

const request = c.get('validatedBody') as ChatRequest;

// Parse act("...") commands from message
const actRegex = /act\("([^"]+)"\)/g;
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: regex doesn't handle escaped quotes within action strings - act("say \"hello\"") would fail to parse correctly

Suggested change
const actRegex = /act\("([^"]+)"\)/g;
const actRegex = /act\("((?:[^"\\]|\\.)*)"\)/g;
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/agent/src/http/HttpServer.ts
Line: 147:147

Comment:
**logic:** regex doesn't handle escaped quotes within action strings - `act("say \"hello\"")` would fail to parse correctly

```suggestion
    const actRegex = /act\("((?:[^"\\]|\\.)*)"\)/g;
```

How can I resolve this? If you propose a fix, please make it concise.

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.

2 participants