Skip to content

Commit 7dfe33b

Browse files
authored
Fix the Computer use sample (#43305)
1 parent d8bc880 commit 7dfe33b

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

sdk/ai/azure-ai-agents/samples/agents_tools/sample_agents_computer_use.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@
4949
MessageInputTextBlock,
5050
MessageInputImageUrlBlock,
5151
RequiredComputerUseToolCall,
52+
ScreenshotAction,
5253
SubmitToolOutputsAction,
54+
ListSortOrder,
5355
)
5456
from azure.identity import DefaultAzureCredential
5557

@@ -152,7 +154,7 @@ def image_to_base64(image_path: str) -> str:
152154
tool_outputs.append(
153155
ComputerToolOutput(tool_call_id=tool_call.id, output=computer_screenshot)
154156
)
155-
if isinstance(action, ComputerScreenshot):
157+
if isinstance(action, ScreenshotAction):
156158
print(f" Screenshot requested")
157159
# (add hook to take screenshot in managed environment API here)
158160

@@ -194,6 +196,12 @@ def image_to_base64(image_path: str) -> str:
194196

195197
print() # extra newline between run steps
196198

199+
messages = agents_client.messages.list(thread_id=thread.id, order=ListSortOrder.ASCENDING)
200+
for msg in messages:
201+
if msg.text_messages:
202+
last_text = msg.text_messages[-1]
203+
print(f"{msg.role}: {last_text.text.value}")
204+
197205
# Optional: Delete the agent once the run is finished.
198206
agents_client.delete_agent(agent.id)
199207
print("Deleted agent")

0 commit comments

Comments
 (0)