How openai/openai-cs-agents-demo works
Main components
a. User (Web Browser)
b. Frontend (Next.js UI)
• app/pages (layout, page.tsx)
• components (Chat, agent-panel, seat-map, guardrails, etc.)
• lib/api.ts (REST client), types, utils
• TailwindCSS, postcss, Next config
c. Backend (Python service)
• api.py (FastAPI/UVicorn entrypoints)
• main.py (initialization)
• Agents Orchestrator (triage, seat-booking, flight-status, cancellation, FAQ)
• Guardrails module
• requirements.txt, python-dotenv for env vars
d. External Services
• OpenAI Agents SDK & OpenAI API endpoints
e. (Optional) Static Data / Assets
• UI public folder, seat-map data
Relationships and data flow
1. User types a message in the chat UI.
2. Frontend lib/api.ts issues HTTP POST to Python backend (e.g., http://localhost:8000/chat).
3. Python API endpoint receives request, loads OPENAI_API_KEY, and passes user input to the Agents Orchestrator.
4. Orchestrator uses the OpenAI Agents SDK:
• Triage Agent decides which specialist to invoke
• Calls relevant Agent (Seat Booking, Flight Status, Cancellation, FAQ)
• Applies Guardrails (Relevance, Jailbreak) at each step
5. Each Agent may call external “tools” or look up static data (e.g., seat-map).
6. SDK sends chat completion requests to the OpenAI API and receives responses.
7. Backend collates final response and guardrail flags, returns JSON to frontend.
8. Frontend UI renders messages, highlights guardrail trips, displays interactive seat map or other components.
Architectural patterns & design principles
• Layered separation: UI layer vs orchestration layer vs external services
• Modular agents: each Agent is a self-contained component (ease of extension)
• Single responsibility: Frontend only handles rendering & user I/O; Backend handles orchestration & API calls
• Stateless backend: relies on OpenAI and in-memory data, no persistent database
Relevant technologies & frameworks
• Next.js (React) with TypeScript, TailwindCSS
• FastAPI (via uvicorn) or equivalent in python-backend
• OpenAI Agents SDK & OpenAI REST API
• python-dotenv for environment variables