Skip to content

Conversation

@jeseed
Copy link
Contributor

@jeseed jeseed commented Sep 27, 2025

No description provided.

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

Summary

This PR implements a comprehensive custom provider system for Cedar-OS, enabling users to define their own LLM provider implementations with flexible configuration.

Key Changes:

  • New Custom Provider Implementation: Added custom.ts with full support for callLLM, callLLMStructured, streamLLM, and voiceLLM methods with intelligent fallbacks
  • Provider Registry Update: Updated the provider registry to map custom provider to its dedicated implementation instead of defaulting to OpenAI
  • Type Safety Enhancements: Extended AgentConnectionTypes.ts with comprehensive typing for custom provider configuration
  • Documentation & Testing: Added detailed bug reproduction documentation and comprehensive test suite for diff history slice issues
  • Example Implementations: Updated playground and product roadmap examples to demonstrate custom provider usage with working examples

Additional Fixes:

  • Identified and documented a critical bug in diff history slice where acceptDiff contaminates original state with diff markers
  • Added comprehensive test coverage for the diff history bug scenario

Minor Issues:

  • Typo in package.json test script
  • Debugger statements left in example code that should be removed for production

Confidence Score: 4/5

  • This PR is safe to merge with minimal risk - implements a solid custom provider system with proper error handling and fallbacks
  • Score reflects well-structured implementation with comprehensive error handling, proper TypeScript typing, and thorough documentation. Minor issues include a typo in package.json and debugger statements that don't affect functionality but should be cleaned up.
  • Pay attention to packages/cedar-os/package.json (typo fix needed) and example files with debugger statements

Important Files Changed

File Analysis

Filename        Score        Overview
packages/cedar-os/package.json 3/5 Contains typo in test:watch script ('watgch' instead of 'watch') that would prevent the command from running
packages/cedar-os/src/store/agentConnection/AgentConnectionTypes.ts 5/5 Updated type definitions to properly support custom provider configuration with flexible function interfaces
packages/cedar-os/src/store/agentConnection/providers/custom.ts 5/5 Implemented comprehensive custom provider with proper fallbacks and error handling for all LLM methods
packages/cedar-os/src/store/agentConnection/providers/index.ts 5/5 Updated provider registry to properly map custom provider to its dedicated implementation instead of defaulting to OpenAI
src/app/examples/cedar-playground/layout.tsx 4/5 Added example custom provider implementation with debugger statements and simulated streaming functionality
src/app/examples/product-roadmap/page.tsx 4/5 Added comprehensive custom provider demo with test functionality and wrapped the entire page with CedarCopilot provider

Sequence Diagram

sequenceDiagram
    participant Client as Client App
    participant Registry as Provider Registry
    participant Custom as Custom Provider
    participant Config as Custom Config
    participant LLM as LLM Functions

    Note over Client, LLM: Custom Provider Implementation Flow

    Client->>Registry: Request provider: "custom"
    Registry->>Custom: Return customProvider implementation
    
    Note over Client, Custom: LLM Call Flow
    Client->>Custom: callLLM(params, config)
    Custom->>Config: Check config.callLLM exists
    alt Custom callLLM provided
        Custom->>LLM: Call config.callLLM(params, config)
        LLM->>Custom: Return LLMResponse
        Custom->>Client: Return response
    else No custom callLLM
        Custom->>Client: Throw error: "requires callLLM function"
    end

    Note over Client, Custom: Streaming Flow
    Client->>Custom: streamLLM(params, config, handler)
    Custom->>Config: Check config.streamLLM exists
    alt Custom streamLLM provided
        Custom->>LLM: Call config.streamLLM(params, config, handler)
        LLM->>Custom: Return StreamResponse
        Custom->>Client: Return StreamResponse
    else Fallback to callLLM
        Custom->>Config: Check config.callLLM exists
        Custom->>LLM: Call config.callLLM(params, config)
        LLM->>Custom: Return LLMResponse
        Custom->>Client: Send chunks via handler
    end

    Note over Client, Custom: Structured Call Flow
    Client->>Custom: callLLMStructured(params, config)
    Custom->>Config: Check config.callLLMStructured exists
    alt Custom structured provided
        Custom->>LLM: Call config.callLLMStructured(params, config)
        LLM->>Custom: Return structured LLMResponse
        Custom->>Client: Return response
    else Fallback to regular callLLM
        Custom->>Config: Check config.callLLM exists
        Custom->>LLM: Call config.callLLM(params, config)
        LLM->>Custom: Return LLMResponse
        Custom->>Client: Return response
    end
Loading

9 files reviewed, 3 comments

Edit Code Review Agent Settings | Greptile

const customProvider: ProviderConfig = {
provider: 'custom',
config: {
callLLM: async (params, config) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Remove debugger statement before production

Suggested change
callLLM: async (params, config) => {
// Debug point for custom provider
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/app/examples/cedar-playground/layout.tsx
Line: 57:57

Comment:
style: Remove debugger statement before production

```suggestion
				// Debug point for custom provider
```

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

content: 'Hello, world!',
};
},
callLLMStructured: async (params, config) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

style: Remove debugger statement before production

Suggested change
callLLMStructured: async (params, config) => {
// Debug point for custom provider structured calls
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/app/examples/cedar-playground/layout.tsx
Line: 63:63

Comment:
style: Remove debugger statement before production

```suggestion
				// Debug point for custom provider structured calls
```

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

@jeseed jeseed merged commit 5ba367d into main Sep 27, 2025
4 of 6 checks passed
@jeseed jeseed deleted the hackathonDocs branch September 27, 2025 19:23
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