Skip to content

add invoke source #1103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

Conversation

iceljc
Copy link
Collaborator

@iceljc iceljc commented Jul 15, 2025

PR Type

Enhancement


Description

  • Add invoke source tracking to function execution hooks

  • Introduce InvokeSource enum with Manual, LLM, and Routing values

  • Update function execution methods to accept source parameter

  • Modify realtime hub to filter notifications based on source


Changes diagram

flowchart LR
  A["InvokeSource enum"] --> B["IConversationHook interface"]
  B --> C["ConversationHookBase class"]
  C --> D["Hook implementations"]
  B --> E["IRoutingService interface"]
  E --> F["RoutingService methods"]
  F --> G["Function execution tracking"]
Loading

Changes walkthrough 📝

Relevant files
Enhancement
15 files
ConversationHookBase.cs
Add invoke source parameter to function hooks                       
+2/-2     
IConversationHook.cs
Update interface with invoke source parameter                       
+4/-2     
InvokeSource.cs
Create InvokeSource enum with constants                                   
+19/-0   
IRoutingService.cs
Add invoke source to routing methods                                         
+2/-2     
RealtimeConversationHook.cs
Filter notifications based on invoke source                           
+4/-3     
RealtimeHub.cs
Pass LLM source to function invocation                                     
+2/-1     
EvaluationConversationHook.cs
Update hook to accept invoke source                                           
+2/-2     
InstructExecutor.cs
Pass LLM and routing sources appropriately                             
+2/-2     
RoutingService.InvokeAgent.cs
Implement invoke source in agent invocation                           
+5/-5     
RoutingService.InvokeFunction.cs
Pass invoke source to function hooks                                         
+3/-3     
RoutingService.cs
Use routing source for direct instructions                             
+1/-1     
RealtimeController.cs
Use LLM source for function execution                                       
+2/-1     
ChatHubConversationHook.cs
Update hook to accept invoke source                                           
+3/-2     
StreamingLogHook.cs
Add invoke source parameter to hooks                                         
+3/-2     
TwilioConversationHook.cs
Update hook signature with invoke source                                 
+5/-4     
Configuration changes
2 files
Using.cs
Add global using for InvokeSource enum                                     
+1/-0     
Using.cs
Add global using for routing enums                                             
+1/-0     
Formatting
1 files
ConversationService.SendMessage.cs
Remove unused InvokeSource import                                               
+0/-1     

Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.
  • Copy link

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Logic Issue

    The filtering logic in OnFunctionExecuted only allows LLM source notifications but the method parameter has a default value of Manual, creating potential confusion about expected behavior.

    if (from != InvokeSource.Llm || hub.HubConn == null)
    {
    Design Concern

    Using static class with const strings instead of enum may lead to typos and lacks compile-time safety. Consider using actual enum type for better type safety.

    public static class InvokeSource
    {
        /// <summary>
        /// Invoke manually
        /// </summary>
        public const string Manual = "manual";
    
        /// <summary>
        /// Invoke by LLM directly
        /// </summary>
        public const string Llm = "llm";
    
        /// <summary>
        /// Invoke by agent routing
        /// </summary>
        public const string Routing = "routing";
    }
    Parameter Inconsistency

    Method signature uses 'from' parameter but the hook calls use named parameter 'from:', which may cause confusion about parameter naming conventions across the codebase.

        await hook.OnFunctionExecuting(clonedMessage, from: from);
    }
    
    bool result = false;
    
    try
    {
        result = await funcExecutor.ExecuteAsync(clonedMessage);
    
        // After functions have been executed
        foreach (var hook in hooks)
        {
            await hook.OnFunctionExecuted(clonedMessage, from: from);

    Copy link

    PR Code Suggestions ✨

    No code suggestions found for the PR.

    @iceljc iceljc requested a review from Oceania2018 July 15, 2025 21:56
    @iceljc iceljc marked this pull request as draft July 15, 2025 22:24
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    1 participant