# Employee Performance Report:

Employee ID: {employee_id}
Program: {program_slug}

Using data returned by:
`get_by_employee_visits('{employee_id}', '{program_slug}')`
`get_employee_sales('{employee_id}', '{program_slug}')`

to generate a detailed, comprehensive employee visit performance report using the pre-calculated metrics.

# 1. Basic Employee Information
**Employee ID:** employee_id
**Employee Name:** employee_name
**Total Stores Visited:** total_stores_visited
**Most Recent Visit Date:** use latest_visit_date from get_by_employee_visits
**Most Recent Store Visited:** show `latest_store_visited` from get_by_employee_visits
**Average Duration of Visits:** use `visit_duration`
**Total Visits:** use `number_of_visits`
**Total Unique Stores Visited:** use `visited_stores`
**Median Duration of Visits:** show `median_visit_duration`
**Visited Retailers**: show `visited_retailers`
## Sales Summary
 **Current Units Sold:** total of `current_sales_current_week`
   Display as total of units sold.
 **Previous Week:** total of `sales_previous_week`
   Display as total of units sold.
 **Week over Week comparison:**

# 2. Visits Summary

Using ONLY the objects in `visit_data` (an array of visits). Do NOT invent data.

Each object at `visit_data` have:
* visit_date
* column_name
* question
* answer
* account_name: Name of retailer (e.g. Best Buy, Lowe's)
* visit_length
* store_id: ID of Store

And visits span over a week.

**Top-3 Longest Duration Visits:** retrieve 3 Longest visits by visit_length
  [Display as a markdown table: | Store ID | Visit Date | visit length (min) | ]
**Top-3 Shortest Duration Visits:** retrieve 3 Shortest visits by visit_length
  [Display as a markdown table: | Store ID | Visit Date | visit length (min) | ]
**Most Frequent Store visited:** count individually each `store_id`, get the most visited store.
**Variance in Average Visit Length:** compare `visit_length` changes across all visits.
**Median Per-Store Visits:** for each `store_id`, count visits; take the median across stores

## Visit Frequency
  - Daily: <avg per day, 2 decimals>
  - most frequent hour: `most_frequent_hour_of_day`
  - most frequent day: `most_frequent_day_of_week`
  - Time Range: `min_time_in`/`max_time_out` (in format hh:mm)

# 3. Sales Performance:
Show Top-3 and Bottom-3 Stores from `get_employee_sales`
[Provide a markdown table with columns: Tier | Store Id | sales_current_week | sales_previous_week | week_over_week_variance]

Using data returned from `get_by_employee_visits` tool executes the following task:

# 4. Visit Performance Metrics

For each of key questions on `visit_data`:
- (Key Wins) Summarize positive outcomes and successes.
- (Challenges/Opportunities) Identify recurring issues and improvement areas.
- (Next Visit Focus) Analyze follow-up priorities and action items.
- (Competitive Landscape): Evaluate market positioning and visibility concerns.
- (Brand visibility): What are your recommendations for improving Brand visibility and positioning?
answer the following questions:

## `column_name`:
• **Top Phrases:** up to 5 frequent key phrases present in `answer` (lower-cased, stemmed/lemmatized).
• **Themes:** Identify business-relevant terms like product names, competitor names, specific issues, store features, customer behaviors referenced in `answer`.
• **Key Issues:** Identify the most frequently mentioned issues or challenges.
  * up to 5 issues/challenges ranked by frequency.
• **Sentiment Counts:** evaluate all `answer` for every VisitAnswer in `visit_data`
  - Positive: X, Negative: Y, Neutral: Z
    *Positive > 0, Negative < 0, Neutral ≈ 0 (TextBlob polarity scale).*
• **Sentiment Analysis:**",
  - Extract one sample answer for positive, negative and neutral from `answer`.
• **\"Most Relevant Answer\":** the answer that best exemplifies the key issues (highest phrase overlap).
• **Insights:** Identify any actionable insights based exclusively on phrases.

INSTRUCTIONS FOR SECTION 5:
1. Work **only** with the literal text inside each `answer`.
2. If none are found, return nothing.

# 5. Visit Comparison – `Visit 1` vs. (`Visit 2` & `Visit 3`)

Rank the rows by visit_timestamp DESC and label them:
- `Visit 1`  = most-recent
- `Visit 2`  = previous-1
- `Visit 3`  = previous-2

For **each** question `column_name` produce:

## Question column_name
• **Sentiment Trend:** ↑ / ↓ / →  (based on net-positive – net-negative)
• **New Issues:** issues appearing **only** in `Visit 1`
• **Resolved Issues:** issues present earlier but **absent** `Visit 1`
• **Persisting Issues:** issues that appear in all visits
• **Notable Phrase Shifts:** any big change in Top Phrases frequency
• **Overall Assessment:** "Better / Worse / No Material Change" with one-sentence rationale
• **Performance Development:** How has the employee's approach or effectiveness changed between visits?

# 6. Summary of Insights
**Summary of Employee Performance:** Use the information extracted to summarize the employee's behavior and performance patterns.
**Sales Performance:** Comparison betwen "bottom" and "top" stores on units sold
**Key Findings:** Summarize the most impactful insights from the analysis.
**Strengths and Successes:** What were the key wins or successes across the employee's recent visits?
**Challenges and Areas for Improvement:** What challenges or opportunities did you observe during the employee's visits?
  - Highlight major issues identified across visits.
  - Areas where performance can be enhanced.
  - Include anything that could be improved or leveraged for future success.
**Performance Trends:** How has the employee's performance changed over time?
**Recommendations:**
    - What specific actions or focus areas should be prioritized for this employee's development?
    - What training or support might help improve their visit quality?
    - What are your recommendations for optimizing their territory coverage and visit efficiency?

IMPORTANT INSTRUCTIONS:
- Strictly follow markdown format without exception.
- Always return EVERY section and sub-section EXACTLY as formatted above.
- NEVER omit, summarize briefly, or indicate additional details elsewhere.
- DO NOT include any introductory summaries, concluding remarks, end notes, or additional text beyond the specified structure.
- NEVER include any disclaimers, warnings, or notes about the data or analysis or phrases as "... from the provided ...".
- Focus on employee performance patterns across multiple stores rather than individual store performance.
- Compare the employee's performance across different stores and time periods.
- Identify consistent strengths and areas for improvement in the employee's approach.
