Skip to content

Rework triage into a robust, structured pipeline#9

Open
trukwava wants to merge 1 commit into
jimenezatmit:mainfrom
trukwava:improve-triage-engine
Open

Rework triage into a robust, structured pipeline#9
trukwava wants to merge 1 commit into
jimenezatmit:mainfrom
trukwava:improve-triage-engine

Conversation

@trukwava

Copy link
Copy Markdown

Summary

Reworks the triage flow to address the three highest-impact issues found while testing the app against sample-messages.json and new examples. Full writeup in IMPROVEMENTS.md.

Top 3 issues fixed

  1. Brittle AI categorization that crashed with no API key. A formatless prompt at temperature 0.7 whose category was recovered by substring-matching the model's prose; and because the Groq client was built at module load, a missing key threw before React mounted and white-screened the app, making the README's "mock mode" unreachable.
  2. Backwards urgency scoring — keyed off punctuation/length/time-of-day instead of meaning, mislabeling 7/10 sample messages ("Server down now" → Low, "Thanks!!!" → High; weekends/after-hours lowered urgency).
  3. Wrong routing & escalation — Feature Requests routed to the billing portal, escalation was message.length > 100 and never called, no team assignment.

Approach

One structured Groq call (JSON mode, temperature 0, a real system prompt + urgency rubric) wrapped in deterministic safety nets:

  • Critical-signal floor — an outage/security/access-loss message can never be ranked below High, even on an LLM miss or offline.
  • Correct per-category routing with an owning team, sharpened at High urgency.
  • Lazy client init + graceful fallback to a local heuristic when there's no key (instead of crashing).
  • Input validation, plus escalation / route-to / confidence / heuristic-mode in the UI.

Verification

  • npm test14/14 (tests/triage.test.mjs) covering the previously-broken cases.
  • Production build clean; changed files lint clean.
  • Verified in the running app: the outage now escalates, the loud thank-you doesn't, and the app renders without a key.

Files

src/utils/llmHelper.js, src/utils/urgencyScorer.js, src/utils/templates.js, src/pages/AnalyzePage.jsx, plus tests/, IMPROVEMENTS.md, and a test script.


Worked as a scoping/judgment exercise: problem framing, prioritization, and review by the submitter; execution paired with Claude Code (AI use is permitted by the program).

🤖 Generated with Claude Code

Replaces the brittle categorizer, the backwards urgency scorer, and the
length-based routing with a single structured AI call plus deterministic
safety nets.

Problems fixed:
- No-API-key white screen: the Groq client was built at module load and
  threw before React mounted, making the advertised "mock mode" unreachable.
  Client is now lazy; a missing/failed key degrades to a local heuristic.
- Categorization was a free-text prompt at temp 0.7 parsed by substring
  matching. Now one Groq call with a system prompt, category enum, JSON mode
  and temp 0, with output validation and safe defaults.
- Urgency scored punctuation/length/time-of-day, inverting reality (7/10
  sample messages mislabeled; "server down now" -> Low, "thanks!!!" -> High).
  Rewritten to score business impact, with a critical-signal floor that can
  never report a clear outage/security/access issue below High.
- Routing sent Feature Requests to the billing portal and escalated on
  message length. Now correct per-category action + owning team, and
  escalation keyed off urgency/critical signal.

Also: input validation, escalation/route-to/confidence in the UI, a
heuristic-mode notice, a committed test (npm test, 14/14), and an
IMPROVEMENTS.md writeup.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.

1 participant