Skip to content

Task3 customer simulator agent - #1

Merged
Shrushti-Sakat merged 2 commits into
mainfrom
task3-customer-simulator-agent
Sep 3, 2026
Merged

Task3 customer simulator agent#1
Shrushti-Sakat merged 2 commits into
mainfrom
task3-customer-simulator-agent

Conversation

@Shrushti-Sakat

Copy link
Copy Markdown
Collaborator

Summary of Changes

Implements Task 3: Customer Simulator Agent as a standalone module for agent training and realistic scenario simulations.

Deliverables Included:

  • 6 configurable personas (calm, confused, frustrated, angry, impatient, polite) in persona_service.py
  • 5 realistic domain scenarios in scenario_service.py
  • Emotional state engine with empathy/dismissive deltas in simulator_state.py
  • Turn-by-turn LLM generation & fallback handling in simulator_service.py
  • API endpoints (POST /simulator/start, POST /simulator/message, GET /simulator/{session_id}/history) in app/api/simulator.py
  • 16 automated pytest tests passing in tests/test_simulator.py
  • Standalone demo conversation generator & log exporter
  • Full mapping documented in TASK3_DELIVERABLES.md

Task 2 Integrity:

All existing Task 2 endpoints, document upload/versioning logic, search, and live support routes have been regression-tested and remain completely unaffected.

New standalone module (models, persona/scenario config, state engine,
LLM turn generation, API endpoints, log export, demo script, 16 pytest tests).
Task 2 (RAG pipeline, chat, documents, support) untouched except a 2-line
router registration in main.py.
@Shrushti-Sakat
Shrushti-Sakat requested review from Anitapandey01 and a lite review from Copilot September 3, 2026 12:35
@vercel

vercel Bot commented Sep 3, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
customer-support-assistant Ready Ready Preview Sep 3, 2026 12:35pm UTC

@Shrushti-Sakat
Shrushti-Sakat merged commit e363a9f into main Sep 3, 2026
3 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The demo script currently exports logs for all completed sessions (not just those created in the run), and there are portability/reliability issues in the new docs/tests that should be corrected before approval.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Implements Task 3 “Customer Simulator Agent” in the backend, adding configurable personas/scenarios, an emotional state engine, turn-by-turn customer response generation, and FastAPI endpoints to run simulator sessions and retrieve histories.

Changes:

  • Added simulator domain libraries (personas, scenarios, state engine) and an LLM-backed turn generator with fallback behavior.
  • Introduced new FastAPI /simulator endpoints for starting sessions, sending turns, and retrieving conversation history.
  • Added demo/log-export scripts plus a dedicated pytest suite for unit + integration coverage.
File summaries
File Description
RAG-Pipeline-backend/tests/test_simulator.py Adds unit + API integration tests for simulator state/services/endpoints.
RAG-Pipeline-backend/TASK3_DELIVERABLES.md Documents Task 3 requirements-to-implementation mapping and run commands.
RAG-Pipeline-backend/scripts/export_simulator_logs.py Exports simulator sessions to JSON log files.
RAG-Pipeline-backend/scripts/demo_simulator_conversations.py Runs standalone demo conversations and triggers log export.
RAG-Pipeline-backend/scripts/create_simulator_table.py Creates simulator DB tables via SQLAlchemy metadata.
RAG-Pipeline-backend/app/services/simulator_state.py Implements emotional state initialization and update rules.
RAG-Pipeline-backend/app/services/simulator_service.py Builds prompts, calls Gemini generation, cleans output, updates state.
RAG-Pipeline-backend/app/services/scenario_service.py Defines scenario templates and brief generation/validation.
RAG-Pipeline-backend/app/services/persona_service.py Defines persona templates and brief generation/validation.
RAG-Pipeline-backend/app/models/simulator.py Adds SQLAlchemy models for scenarios/sessions/conversations/messages.
RAG-Pipeline-backend/app/main.py Registers the new simulator router.
RAG-Pipeline-backend/app/api/simulator.py Implements /simulator endpoints and DB interactions.
RAG-Pipeline-backend/.gitignore Ignores generated simulator logs and test DB artifacts.
Review details

Suppressed comments (3)

RAG-Pipeline-backend/TASK3_DELIVERABLES.md:17

  • These links also use local file:/// paths. Switching to repo-relative links keeps the doc usable in GitHub and in non-Windows environments.
| **Sample Conversation Logs** | [`logs/simulator/*.json`](file:///c:/Users/shrushti/Customer-Support-Assistant/RAG-Pipeline-backend/logs/simulator), generated via [`scripts/demo_simulator_conversations.py`](file:///c:/Users/shrushti/Customer-Support-Assistant/RAG-Pipeline-backend/scripts/demo_simulator_conversations.py) |
| **Test Cases Covering Customer Behaviors** | [`tests/test_simulator.py`](file:///c:/Users/shrushti/Customer-Support-Assistant/RAG-Pipeline-backend/tests/test_simulator.py) (16 automated tests via `pytest tests/test_simulator.py -v`) |

RAG-Pipeline-backend/scripts/demo_simulator_conversations.py:285

  • This exports logs for all previously completed sessions in the database, not just the sessions created in this demo run. That can produce unexpected extra log files and make the output count inaccurate. Export only completed_session_ids collected during this run.
    exported_files = export_all_completed_sessions(output_dir="logs/simulator")

RAG-Pipeline-backend/tests/test_simulator.py:43

  • Using a fixed test_simulator.db in the working directory can collide across parallel pytest workers and can leave artifacts behind if tests abort. Prefer a unique temp-file location and build the SQLite URL from the absolute path.
TEST_DB_FILE = "test_simulator.db"
TEST_DATABASE_URL = f"sqlite:///./{TEST_DB_FILE}"
  • Files reviewed: 13/13 changed files
  • Comments generated: 4
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

from app.services.simulator_service import generate_customer_turn
from app.services.simulator_state import initial_state
from app.services.scenario_service import SCENARIOS
from scripts.export_simulator_logs import export_all_completed_sessions
Comment on lines +11 to +15
| **Customer Simulator Agent** | [`app/services/simulator_service.py`](file:///c:/Users/shrushti/Customer-Support-Assistant/RAG-Pipeline-backend/app/services/simulator_service.py) |
| **Persona and Scenario Configuration** | [`app/services/persona_service.py`](file:///c:/Users/shrushti/Customer-Support-Assistant/RAG-Pipeline-backend/app/services/persona_service.py) (6 personas) & [`app/services/scenario_service.py`](file:///c:/Users/shrushti/Customer-Support-Assistant/RAG-Pipeline-backend/app/services/scenario_service.py) (5 scenarios) |
| **Emotion / State Management** | [`app/services/simulator_state.py`](file:///c:/Users/shrushti/Customer-Support-Assistant/RAG-Pipeline-backend/app/services/simulator_state.py) (`initial_state`, `update_state`, `is_resolved`, `is_escalated`) |
| **Turn-by-Turn Response Generation** | `generate_customer_turn()` in [`app/services/simulator_service.py`](file:///c:/Users/shrushti/Customer-Support-Assistant/RAG-Pipeline-backend/app/services/simulator_service.py) |
| **API Integration** | [`app/api/simulator.py`](file:///c:/Users/shrushti/Customer-Support-Assistant/RAG-Pipeline-backend/app/api/simulator.py) (`POST /simulator/start`, `POST /simulator/message`, `GET /simulator/{session_id}/history`) |
Comment on lines +8 to +13
from app.services.simulator_state import (
initial_state,
update_state,
is_resolved,
is_escalated,
)
Comment on lines +3 to +6
import os
import sys
from unittest.mock import MagicMock
import pytest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants