Skip to content

Commit 6d1f1ac

Browse files
Fix ChatMessage API usage in docstrings and source
- Fix ChatMessage positional args in docstrings: _serialization.py, _threads.py, _middleware.py - Fix ChatMessage in tau2 runner.py - Fix role comparison in _orchestrator_helpers.py to use .value - Fix role comparison in _group_chat.py docstring example - Fix role assertions in test_durable_entities.py to use .value
1 parent d42c470 commit 6d1f1ac

6 files changed

Lines changed: 12 additions & 11 deletions

File tree

.github/workflows/python-merge-tests.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,7 @@ jobs:
9696
uses: ./.github/actions/azure-functions-integration-setup
9797
id: azure-functions-setup
9898
- name: Test with pytest
99-
timeout-minutes: 15
100-
run: uv run poe all-tests -n logical --dist loadfile --dist worksteal --timeout 60 --timeout_method thread --timeout-verbose --retries 2 --retry-delay 5
99+
run: uv run poe all-tests -n logical --dist loadfile --dist worksteal --session-timeout=900 --timeout_method thread --retries 2 --retry-delay 5
101100
working-directory: ./python
102101
- name: Test core samples
103102
timeout-minutes: 10
@@ -154,7 +153,7 @@ jobs:
154153
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
155154
- name: Test with pytest
156155
timeout-minutes: 15
157-
run: uv run --directory packages/azure-ai poe integration-tests -n logical --dist loadfile --dist worksteal --timeout 60 --timeout_method thread --timeout-verbose --retries 2 --retry-delay 5
156+
run: uv run --directory packages/azure-ai poe integration-tests -n logical --dist loadfile --dist worksteal --session-timeout=900 --timeout_method thread --retries 2 --retry-delay 5
158157
working-directory: ./python
159158
- name: Test Azure AI samples
160159
timeout-minutes: 10

python/packages/core/agent_framework/_middleware.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ async def process(self, context: ChatContext, next):
490490
# Add system prompt to messages
491491
from agent_framework import ChatMessage
492492
493-
context.messages.insert(0, ChatMessage("system", [self.system_prompt]))
493+
context.messages.insert(0, ChatMessage(role="system", text=self.system_prompt))
494494
495495
# Continue execution
496496
await next(context)

python/packages/core/agent_framework/_serialization.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class SerializationProtocol(Protocol):
3838
3939
4040
# ChatMessage implements SerializationProtocol via SerializationMixin
41-
user_msg = ChatMessage("user", ["What's the weather like today?"])
41+
user_msg = ChatMessage(role="user", text="What's the weather like today?")
4242
4343
# Serialize to dictionary - automatic type identification and nested serialization
4444
msg_dict = user_msg.to_dict()
@@ -175,8 +175,8 @@ class SerializationMixin:
175175
# ChatMessageStoreState handles nested ChatMessage serialization
176176
store_state = ChatMessageStoreState(
177177
messages=[
178-
ChatMessage("user", ["Hello agent"]),
179-
ChatMessage("assistant", ["Hi! How can I help?"]),
178+
ChatMessage(role="user", text="Hello agent"),
179+
ChatMessage(role="assistant", text="Hi! How can I help?"),
180180
]
181181
)
182182

python/packages/core/agent_framework/_threads.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ class ChatMessageStore:
202202
store = ChatMessageStore()
203203
204204
# Add messages
205-
message = ChatMessage("user", ["Hello"])
205+
message = ChatMessage(role="user", text="Hello")
206206
await store.add_messages([message])
207207
208208
# Retrieve messages

python/packages/core/agent_framework/_workflows/_group_chat.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,9 @@ def with_termination_condition(self, termination_condition: TerminationCondition
782782
783783
784784
def stop_after_two_calls(conversation: list[ChatMessage]) -> bool:
785-
calls = sum(1 for msg in conversation if msg.role == "assistant" and msg.author_name == "specialist")
785+
calls = sum(
786+
1 for msg in conversation if msg.role.value == "assistant" and msg.author_name == "specialist"
787+
)
786788
return calls >= 2
787789
788790

python/packages/lab/tau2/agent_framework_lab_tau2/runner.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,11 +338,11 @@ async def run(
338338
# Matches tau2's expected conversation start pattern
339339
logger.info(f"Starting workflow with hardcoded greeting: '{DEFAULT_FIRST_AGENT_MESSAGE}'")
340340

341-
first_message = ChatMessage("assistant", text=DEFAULT_FIRST_AGENT_MESSAGE)
341+
first_message = ChatMessage(role="assistant", text=DEFAULT_FIRST_AGENT_MESSAGE)
342342
initial_greeting = AgentExecutorResponse(
343343
executor_id=ASSISTANT_AGENT_ID,
344344
agent_response=AgentResponse(messages=[first_message]),
345-
full_conversation=[ChatMessage("assistant", text=DEFAULT_FIRST_AGENT_MESSAGE)],
345+
full_conversation=[ChatMessage(role="assistant", text=DEFAULT_FIRST_AGENT_MESSAGE)],
346346
)
347347

348348
# STEP 4: Execute the workflow and collect results

0 commit comments

Comments
 (0)