diff --git a/litellm/llms/github_copilot/common_utils.py b/litellm/llms/github_copilot/common_utils.py index 11e86948621..2976d892ff7 100644 --- a/litellm/llms/github_copilot/common_utils.py +++ b/litellm/llms/github_copilot/common_utils.py @@ -188,8 +188,8 @@ def determine_x_initiator(messages_or_input: Union[list, str]) -> str: # No role = agent-initiated (Responses API role-less item types) if role is None: return "agent" - # assistant or tool role = agent continuation - if role in ("assistant", "tool"): + # assistant, tool, or legacy function role = agent continuation + if role in ("assistant", "tool", "function"): return "agent" return "user" diff --git a/tests/llm_responses_api_testing/test_github_copilot_billing.py b/tests/integration/github_copilot/test_github_copilot_billing.py similarity index 100% rename from tests/llm_responses_api_testing/test_github_copilot_billing.py rename to tests/integration/github_copilot/test_github_copilot_billing.py diff --git a/tests/test_litellm/llms/github_copilot/test_conversation_id.py b/tests/test_litellm/llms/github_copilot/test_conversation_id.py index aa94f9504f0..7f7f90ed016 100644 --- a/tests/test_litellm/llms/github_copilot/test_conversation_id.py +++ b/tests/test_litellm/llms/github_copilot/test_conversation_id.py @@ -129,5 +129,13 @@ class TestDetermineXInitiator: def test_string_input_returns_user(self): assert determine_x_initiator("What is 2+2?") == "user" + def test_legacy_function_role_returns_agent(self): + """Deprecated role:function must be treated as agent continuation.""" + messages = [ + {"role": "user", "content": "Call a function"}, + {"role": "function", "content": "result", "name": "my_fn"}, + ] + assert determine_x_initiator(messages) == "agent" + def test_empty_list_returns_user(self): assert determine_x_initiator([]) == "user"