Skill 2.1.5
Create a lightweight client application for an agent
Key Concepts
The client connects to the project with AIProjectClient and DefaultAzureCredential, then obtains an OpenAI client bound to the agent with project.get_openai_client(agent_name="..."). It creates a conversation with conversations.create() and, for each user message, calls responses.create(conversation=conversation.id, input=message). The agent's configuration, including its instructions and tools, is applied by the service, and the conversation stores the history so that follow-up questions keep their context.
The response's output_text contains the agent's answer, and its output list shows the items produced during the run, such as file search calls or messages. Built-in tools run in the service; a function tool is different, because the agent returns a function call that the client application must execute and send back as a function call output. Because the agent definition lives in Foundry, it can be improved and versioned without changing the client code.