How badrinath63/self-improving-appointment-agent works
This repository provides a patient-facing appointment scheduling agent and a separate evaluation/improvement loop. The main workflow is patient message → FastAPI chat endpoint → agent conversation and tool dispatch → mock clinic data for doctor search, availability, booking, or cancellation → response with tool trace. Evaluation runs predefined scenarios through the agent, scores responses and traces, applies structured policy rules, then reruns scenarios for regression checks. The graph follows documented capabilities where source was not sampled; those unsampled implementation details are not asserted as code-level links.
Main entry points: agent.py Agent orchestration · run.py Evaluation runner · main.py Chat API · tools.py Appointment tools
Components 14
Patient interaction
- Chat API
app/main.py - Chat schemas
app/schemas.py
Scheduling runtime
- Agent orchestration
app/agent.py - OpenRouter model
- Session state
app/state.py - Appointment tools
app/tools.py - Mock clinic data
app/database.py
Evaluation loop
- Evaluation scenarios
evaluation/scenarios.py - Evaluation runner
evaluation/run.py - Scenario evaluator
evaluation/evaluator.py - Improvement logic
evaluation/improvement.py
Agent policy
- Prompt builder
app/prompts.py - Policy rules
improvements/policy.json
Other components
- Patient
Connections 15
- Patient → Chat API: sends message
README.md - Chat API → Chat schemas: validates and formats
app/main.py - Chat API → Agent orchestration: invokes
app/main.py - Agent orchestration → OpenRouter model: requests completion
app/agent.py - Agent orchestration → Session state: reads and updates
app/agent.py - Agent orchestration → Prompt builder: builds instructions
app/agent.py - Prompt builder → Policy rules: loads rules
app/prompts.py - Agent orchestration → Appointment tools: dispatches tool calls
app/agent.py - Appointment tools → Mock clinic data: reads and updates
app/tools.py - Evaluation runner → Evaluation scenarios: runs scenarios
evaluation/run.py - Evaluation runner → Agent orchestration: runs conversation
evaluation/run.py - Evaluation runner → Mock clinic data: resets state
evaluation/run.py - Evaluation runner → Scenario evaluator: scores results
evaluation/run.py - Evaluation runner → Improvement logic: applies improvements
evaluation/run.py - Improvement logic → Policy rules: updates policy
evaluation/improvement.py