semantic-kernel icon indicating copy to clipboard operation
semantic-kernel copied to clipboard

Python: Bug Report: Arguments Parameter Ignored in ResponsesAgentThreadActions.invoke()

Open Skylertodd opened this issue 1 year ago • 0 comments

Bug Report: Arguments Parameter Ignored in ResponsesAgentThreadActions.invoke()

Summary

The invoke method in ResponsesAgentThreadActions class ignores the arguments parameter due to incorrect usage of kwargs.get("arguments") instead of the named parameter.

Location

  • File: semantic_kernel/agents/open_ai/responses_agent_thread_actions.py
  • Line: 259
  • Method: ResponsesAgentThreadActions.invoke() https://github.com/microsoft/semantic-kernel/blob/4e9ea783903b5428debd777e5496bba997b5a150/python/semantic_kernel/agents/open_ai/responses_agent_thread_actions.py#L259

Problem Description

The method signature explicitly defines arguments as a named parameter:

@classmethod
async def invoke(
    cls: type[_T],
    *,
    agent: "OpenAIResponsesAgent",
    chat_history: "ChatHistory",
    thread: "ResponsesAgentThread",
    store_enabled: bool,
    function_choice_behavior: "FunctionChoiceBehavior",
    arguments: KernelArguments | None = None,  # ← Named parameter
    # ... other parameters ...
    **kwargs: Any,
) -> AsyncIterable[tuple[bool, "ChatMessageContent"]]:

However, at line 236, the code incorrectly tries to access arguments from kwargs:

# Line 259 - INCORRECT
arguments=kwargs.get("arguments"),

Root Cause

In Python, when a parameter is explicitly named in the method signature, it is not included in **kwargs. Therefore, kwargs.get("arguments") will always return None, regardless of what value was passed for the arguments parameter.

Impact

  • Any KernelArguments passed to the invoke method are completely ignored
  • None is always passed to kernel.invoke_function_call() instead of the intended arguments
  • Function calls may not receive their required arguments, potentially causing failures or unexpected behavior

Expected Behavior

The code should use the named parameter directly:

# Line 259 - CORRECT
arguments=arguments,

Reproduction

  1. Call ResponsesAgentThreadActions.invoke() with a non-None arguments parameter
  2. Observe that the arguments are not passed through to kernel.invoke_function_call()
  3. The function call will receive None instead of the provided arguments

Suggested Fix

Change line 259 from:

arguments=kwargs.get("arguments"),

To:

arguments=arguments,

Additional Context

This appears to be a refactoring oversight where:

  1. Originally arguments may have been passed via **kwargs
  2. Later refactored to be an explicit parameter
  3. The usage was not updated to match the new signature

This bug affects the core functionality of the OpenAI Responses Agent and should be prioritized for fixing.

Skylertodd avatar Sep 02 '25 15:09 Skylertodd