Create Microsoft Foundry Agents with Python SDK: Part 1

Build Microsoft Foundry Agents with Python SDK: Part 1: AGENTIC AI Set up agents from scratch, add tools, install guardrails, etc. Introduction As the title suggests, we will be learning how to create agents using Foundry’s python SDK. Before we begin, some of you may ask — what’s wrong with using the Foundry UI to create agents? The simple answer is — Nothing really. In fact I urge you to try creating an agent using a few clicks on the Foundry UI to understand where to see: * the instructions (and use AI to even write them instead of starting from scratch). For instance, here I am explicitly forcing a guided approach for my researcher-agent, where the agent must identify and get the topics approved before it starts generating them. Use AI to write the instructions for an agent * the version (and compare different agent versions to see which offers the best output). On the left, latest v7 version: the agent uses the web search tool and follows our instructions to confirm the topics with the end users first before it starts generating the research report ; whereas in the older v1 version on the right, it lacked access to any tool and it would start producing an output from the get go without a human-in-the-loop to verify the topics first. Compare different versions of an agent with the same input * the run trace to assess the input/output/tooluse, etc. This is highly beneficial for debugging agent responses if they lack quality, decent latency, or showcase signs of hallucinations. Run traces for each agent interaction Once you’ve had a good look and feel of the playground, you are ready to move onto the next step. While you can keep using the platform’s UI for manual agent creation, the Foundry SDK allows for automation, scalability and integration into your own application. In more practical terms, there are a few things that can only be done via the SDK: * implementing custom functions as tools (for example: get_user_info()to let the agent fetch a user’s record before further processing). * enriching traces with metadata (for example: adding custom attributes like customer_tier: “gold” programatically to filter traces in portal to find specifically why “gold” tier users are experiencing high latency) * logging client-side traces (for ex: user_id, app_version, retries, queuing, time spent waiting before you even call responses.create()) and merging them with server side traces (response time, error rate, intermediate steps by agent, tool call, etc). Since the UI portal allows out-of-box access to server-side traces only i.e. what’s happening on the cloud platform, without the SDK, your app’s logic and foundry portal’s traces are two separate puzzles that don’t fit together. (for ex: when something goes wrong, Foundry’s server trace won’t tell you which user workflow, which app version, or which feature flag produced the call). Later on in Part 2,… #genai #shared #ai

To view or add a comment, sign in

Explore content categories