Skip to content

Conversation

@echobt
Copy link
Contributor

@echobt echobt commented Feb 4, 2026

Summary

Adds serde aliases to the Glob tool handler to support both snake_case and camelCase parameter names for better client compatibility.

Problem

The Glob tool only accepts snake_case parameter names (exclude_patterns, directory), but some clients may send camelCase variants. This creates inconsistency with other tools that support both conventions.

Changes

  • Added #[serde(alias = "excludePatterns")] to exclude_patterns field
  • Added #[serde(alias = "folder")] to directory field for consistency with tool definition

Testing

  • Verified code compiles with cargo check -p cortex-engine

Verification

cargo check -p cortex-engine

@greptile-apps
Copy link

greptile-apps bot commented Feb 4, 2026

Greptile Overview

Greptile Summary

This PR adds serde aliases to tool handlers for better client compatibility and includes several code quality improvements.

Main Changes:

  • Added serde aliases to Glob handler (excludePatternsexclude_patterns, folderdirectory) and Grep handler (head_limitmax_results) to support both snake_case and camelCase parameter naming conventions
  • Replaced unwrap() with unwrap_or_default() in SystemTime operations to handle potential time errors gracefully
  • Removed dead code including unused reconnection methods, unused struct fields, and #[allow(dead_code)] annotations
  • Extracted magic timeout numbers into named constants with clear documentation
  • Added comprehensive timeout hierarchy documentation across the codebase

Note: The PR title mentions only the Glob handler fix, but this PR contains 7 commits spanning multiple improvements (tool compatibility, timeout refactoring, dead code cleanup, auth fixes, and documentation). While all changes appear sound individually, bundling unrelated changes makes it harder to track which commit addresses which issue and complicates potential rollbacks.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • All changes are straightforward improvements with no breaking changes: serde aliases maintain backward compatibility, unwrap_or_default provides safer error handling, dead code removal has no runtime impact, and timeout constant extraction improves maintainability. The code compiles successfully and the changes follow Rust best practices.
  • No files require special attention

Important Files Changed

Filename Overview
src/cortex-engine/src/tools/handlers/glob.rs Added serde aliases for exclude_patterns (alias: excludePatterns) and directory (alias: folder) to support both snake_case and camelCase parameter names
src/cortex-engine/src/tools/handlers/grep.rs Added serde alias head_limit for max_results field to support alternative parameter naming
src/cortex-app-server/src/auth.rs Replaced .unwrap() with .unwrap_or_default() in three SystemTime operations to handle potential time errors gracefully
src/cortex-tui/src/runner/event_loop/streaming.rs Extracted magic timeout numbers into named constants STREAMING_CONNECTION_TIMEOUT (60s) and STREAMING_CHUNK_TIMEOUT (30s)
src/cortex-common/src/http_client.rs Added comprehensive timeout configuration documentation table explaining the timeout hierarchy across all Cortex services

Sequence Diagram

sequenceDiagram
    participant Client
    participant ToolHandler
    participant GlobHandler
    participant GrepHandler
    participant FileSystem

    Note over Client,FileSystem: Tool Parameter Compatibility Enhancement

    Client->>ToolHandler: Request with camelCase params<br/>(excludePatterns, folder, head_limit)
    
    alt Glob Tool
        ToolHandler->>GlobHandler: deserialize with serde aliases
        Note over GlobHandler: alias "excludePatterns" → exclude_patterns<br/>alias "folder" → directory
        GlobHandler->>GlobHandler: Parse parameters (snake_case or camelCase)
        GlobHandler->>FileSystem: Execute glob search
        FileSystem-->>GlobHandler: Return matching files
        GlobHandler-->>ToolHandler: ToolResult
    else Grep Tool
        ToolHandler->>GrepHandler: deserialize with serde aliases
        Note over GrepHandler: alias "head_limit" → max_results
        GrepHandler->>GrepHandler: Parse parameters (snake_case or camelCase)
        GrepHandler->>FileSystem: Execute grep search
        FileSystem-->>GrepHandler: Return matching content
        GrepHandler-->>ToolHandler: ToolResult
    end
    
    ToolHandler-->>Client: Success response
Loading

Copy link

@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.

5 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@echobt
Copy link
Contributor Author

echobt commented Feb 4, 2026

Changes already included in #75 - fix(tools): consolidated tools parameter aliases and handler name fixes

@echobt echobt closed this Feb 4, 2026
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.

1 participant