Skip to content

Commit 6c49d71

Browse files
Copilotpontemonti
andcommitted
Address PR feedback: update copyright headers, remove example file, use TurnContext, remove auth
Co-authored-by: pontemonti <[email protected]>
1 parent 6545d57 commit 6c49d71

File tree

15 files changed

+51
-95
lines changed

15 files changed

+51
-95
lines changed

examples/send_chat_history_example.py

Lines changed: 0 additions & 64 deletions
This file was deleted.

libraries/microsoft-agents-a365-runtime/microsoft_agents_a365/runtime/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# Copyright (c) Microsoft. All rights reserved.
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
23

34
from .environment_utils import get_observability_authentication_scope
45
from .operation_error import OperationError

libraries/microsoft-agents-a365-runtime/microsoft_agents_a365/runtime/operation_error.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# Copyright (c) Microsoft. All rights reserved.
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
23

34
"""
45
Encapsulates an error from an operation.

libraries/microsoft-agents-a365-runtime/microsoft_agents_a365/runtime/operation_result.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# Copyright (c) Microsoft. All rights reserved.
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
23

34
"""
45
Represents the result of an operation.

libraries/microsoft-agents-a365-tooling/microsoft_agents_a365/tooling/models/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# Copyright (c) Microsoft. All rights reserved.
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
23

34
"""
45
Common models for MCP tooling.

libraries/microsoft-agents-a365-tooling/microsoft_agents_a365/tooling/models/chat_history_message.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# Copyright (c) Microsoft. All rights reserved.
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
23

34
"""
45
Chat History Message model.

libraries/microsoft-agents-a365-tooling/microsoft_agents_a365/tooling/models/chat_message_request.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# Copyright (c) Microsoft. All rights reserved.
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
23

34
"""
45
Chat Message Request model.

libraries/microsoft-agents-a365-tooling/microsoft_agents_a365/tooling/services/mcp_tool_server_configuration_service.py

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# Copyright (c) Microsoft. All rights reserved.
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
23

34
"""
45
MCP Tool Server Configuration Service.
@@ -500,22 +501,16 @@ def _validate_server_strings(self, name: Optional[str], unique_name: Optional[st
500501

501502
async def send_chat_history(
502503
self,
503-
conversation_id: str,
504-
message_id: str,
505-
user_message: str,
504+
turn_context,
506505
chat_history_messages: List[ChatHistoryMessage],
507-
auth_token: str,
508506
options: Optional[ToolOptions] = None,
509507
):
510508
"""
511509
Sends chat history to the MCP platform for real-time threat protection.
512510
513511
Args:
514-
conversation_id: The unique identifier for the conversation.
515-
message_id: The unique identifier for the message within the conversation.
516-
user_message: The content of the user's message.
512+
turn_context: TurnContext from the Agents SDK containing conversation information.
517513
chat_history_messages: List of ChatHistoryMessage objects representing the chat history.
518-
auth_token: Authentication token to access the MCP platform.
519514
options: Optional ToolOptions instance containing optional parameters.
520515
521516
Returns:
@@ -531,16 +526,29 @@ async def send_chat_history(
531526
from ..utils.utility import get_chat_history_endpoint
532527

533528
# Validate input parameters
529+
if not turn_context:
530+
raise ValueError("turn_context cannot be empty or None")
531+
if not chat_history_messages:
532+
raise ValueError("chat_history_messages cannot be empty or None")
533+
534+
# Extract required information from turn context
535+
if not turn_context.activity:
536+
raise ValueError("turn_context.activity cannot be None")
537+
538+
conversation_id = (
539+
turn_context.activity.conversation.id
540+
if turn_context.activity.conversation
541+
else None
542+
)
543+
message_id = turn_context.activity.id
544+
user_message = turn_context.activity.text
545+
534546
if not conversation_id:
535-
raise ValueError("conversation_id cannot be empty or None")
547+
raise ValueError("conversation_id cannot be empty or None (from turn_context.activity.conversation.id)")
536548
if not message_id:
537-
raise ValueError("message_id cannot be empty or None")
549+
raise ValueError("message_id cannot be empty or None (from turn_context.activity.id)")
538550
if not user_message:
539-
raise ValueError("user_message cannot be empty or None")
540-
if not chat_history_messages:
541-
raise ValueError("chat_history_messages cannot be empty or None")
542-
if not auth_token:
543-
raise ValueError("auth_token cannot be empty or None")
551+
raise ValueError("user_message cannot be empty or None (from turn_context.activity.text)")
544552

545553
# Use default options if none provided
546554
if options is None:
@@ -560,9 +568,8 @@ async def send_chat_history(
560568
)
561569

562570
try:
563-
# Prepare headers
571+
# Prepare headers (no authentication required)
564572
headers = {
565-
Constants.Headers.AUTHORIZATION: f"{Constants.Headers.BEARER_PREFIX} {auth_token}",
566573
Constants.Headers.USER_AGENT: RuntimeUtility.get_user_agent_header(
567574
options.orchestrator_name
568575
),

libraries/microsoft-agents-a365-tooling/microsoft_agents_a365/tooling/utils/utility.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# Copyright (c) Microsoft. All rights reserved.
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
23

34
"""
45
Provides utility functions for the Tooling components.

tests/runtime/test_operation_error.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# Copyright (c) Microsoft. All rights reserved.
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
23

34
"""Unit tests for OperationError class."""
45

0 commit comments

Comments
 (0)