How hieumoscow/azure-openai-agents works
Project Type and Purpose
• This is a backend-focused demo application (no web UI in this repo). It’s a standalone Python service that:
• Hosts multiple OpenAI Agents (Customer Service, Loan Specialist, Investment Specialist, Banking Assistant)
• Exposes “tools” (check_account_balance, calculate_loan_payment)
• Connects to Azure OpenAI (direct or via APIM)
• Emits telemetry via Logfire → OpenTelemetry → Azure Application Insights
File Structure
• main.py: Entry point. Configures Logfire, instruments OpenAI Agents, kicks off demo workflow.
• fixed_openai_agents.py: Patches Agent SDK for correct span naming in telemetry.
• otel-collector-config.yaml: Defines local OTLP receiver and Azure Monitor exporter.
• requirements.txt/.env.sample: Dependencies and environment variables for Azure OpenAI vs. APIM.
• assets/: Demo video and gif for Application Insights dashboard.
Extract Key Architecture Elements
a. Components
• User (CLI or script runner)
• BankingAgentService (the Python app)
• Agent Orchestrator (OpenAI Agents SDK)
• Agents (Customer Service, Loan, Investment, Banking Assistant)
• Tools Layer (check_account_balance, calculate_loan_payment)
• External Systems
• Azure OpenAI endpoint (or Azure API Management layer)
• (Optional) Bank backend APIs for real data
• Telemetry Pipeline
• Logfire instrumentation
• Local OTLP receiver (otel-collector)
• Azure Application Insights
b. Interactions & Data Flows
1. User → BankingAgentService: User invokes main.py (e.g., CLI input).
2. Agent Orchestrator chooses appropriate Agent based on input.
3. Agent → Azure OpenAI: Sends ChatCompletion or Agent API calls.
4. Agent → Tools Layer: If a “tool” is invoked (e.g., check balance), calls internal function or external bank API.
5. Telemetry: All calls are instrumented by Logfire → emitted as OTLP → collected by otel-collector → forwarded to Azure Application Insights.
c. Architectural Patterns/Principles
• Agent-Based Orchestration: Decoupled, each Agent has its own domain knowledge & toolset.
• Handoff Workflow: Customer Service Agent delegates to specialists.
• Sidecar-style Telemetry: Application and collector run separately but communicate via OTLP.
• Configuration-driven: Environment variables select direct vs. APIM connection.
Putting It All Together
• In the center, group:
[BankingAgentService]
– Orchestrator
– Tools Layer