Skip to content

Commit ebc6318

Browse files
authored
Update bing-code-samples.md
1 parent b6aad4c commit ebc6318

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

articles/ai-foundry/agents/how-to/tools/bing-code-samples.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,32 @@ if run.status == "failed":
129129
messages = project_client.agents.messages.list(thread_id=thread.id)
130130
for message in messages:
131131
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+
```
132155

133-
# Delete the agent when done
156+
## Delete the agent when done
157+
```python
134158
project_client.agents.delete_agent(agent.id)
135159
print("Deleted agent")
136160
```

0 commit comments

Comments
 (0)