File tree Expand file tree Collapse file tree 1 file changed +25
-1
lines changed
articles/ai-foundry/agents/how-to/tools Expand file tree Collapse file tree 1 file changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -129,8 +129,32 @@ if run.status == "failed":
129
129
messages = project_client.agents.messages.list(thread_id = thread.id)
130
130
for message in messages:
131
131
print (f " Role: { message.role} , Content: { message.content} " )
132
+ ```
133
+
134
+ ## Optionally output the run steps used by the agent
135
+ ``` python
136
+ run_steps = project_client.agents.run_steps.list(thread_id = thread.id, run_id = run.id)
137
+ for step in run_steps:
138
+ print (f " Step { step[' id' ]} status: { step[' status' ]} " )
139
+
140
+ # Check if there are tool calls in the step details
141
+ step_details = step.get(" step_details" , {})
142
+ tool_calls = step_details.get(" tool_calls" , [])
143
+
144
+ if tool_calls:
145
+ print (" Tool calls:" )
146
+ for call in tool_calls:
147
+ print (f " Tool Call ID: { call.get(' id' )} " )
148
+ print (f " Type: { call.get(' type' )} " )
149
+
150
+ function_details = call.get(" function" , {})
151
+ if function_details:
152
+ print (f " Function name: { function_details.get(' name' )} " )
153
+ print () # add an extra newline between steps
154
+ ```
132
155
133
- # Delete the agent when done
156
+ ## Delete the agent when done
157
+ ``` python
134
158
project_client.agents.delete_agent(agent.id)
135
159
print (" Deleted agent" )
136
160
```
You can’t perform that action at this time.
0 commit comments