Skip to content

feat(ai-orchestrator): improve mesh router classification for inferred/generic queries#143

Merged
SteveJRobertson merged 3 commits into
mainfrom
142-improve-mesh-router-classification
Jun 4, 2026
Merged

feat(ai-orchestrator): improve mesh router classification for inferred/generic queries#143
SteveJRobertson merged 3 commits into
mainfrom
142-improve-mesh-router-classification

Conversation

@SteveJRobertson

Copy link
Copy Markdown
Owner

Summary

Closes #142

Update the mesh router to enable LLM-based inference of the best-fit specialist persona for generic /query commands, rather than returning null when no explicit persona tag is present. The webhook-listener already prefixes all /query commands with @isolate-, ensuring every manual query reaches the LLM for classification.

Key improvement: Generic queries like "What is the status of this issue?" now route to the po (Product Owner) persona instead of silently failing or being routed to an unrelated specialist (e.g., docs or a11y).

Changes

Core Changes

  • libs/ai-orchestrator/src/orchestrator/mesh-router.ts — Updated MESH_SYSTEM_PROMPT to include:
    • Persona domain descriptions for all 6 specialists (po, architect, dev, a11y, qa, docs)
    • Explicit instructions for inferring best-fit persona from generic query content
    • Examples showing how status questions route to po, architecture questions to architect, accessibility questions to a11y
    • Clarification that explicit @isolate-<persona> tags override inference
    • Preserved deterministic JSON output format and defensive parsing logic

Test Changes

  • libs/ai-orchestrator/src/tests/mesh-router.spec.ts — Added 8 new test cases:
    • 6 tests for generic query inference covering po, architect, and a11y domains
    • 2 tests validating MESH_SYSTEM_PROMPT constant (all personas present, required keywords present)
    • All tests use mocked LLM responses to avoid API calls
    • All existing tests continue to pass (no regressions)

Configuration Changes

  • Exported MESH_SYSTEM_PROMPT constant so it can be tested directly

Copilot Review Triage

  • Blocker — No security/correctness violations found
  • Major — No reliability or async/error handling issues
  • Minor — Prompt constant validation tests ensure no regression
  • Nit — Code style and naming conventions followed

Deferred follow-ups

None. Issue #142 is fully complete in this PR.


Testing: All 496 tests pass (289 ai-orchestrator tests including 8 new mesh-router tests). Full test suite validates no regressions across all projects.

Add 6 test cases for mesh router generic query inference:
- Status/requirement queries route to po
- Architecture/tooling queries route to architect
- Accessibility/compliance queries route to a11y
Validate that MESH_SYSTEM_PROMPT includes all 6 persona domains and
contains required routing instruction keywords. This prevents accidental
prompt regression during future refactors.
Copilot AI review requested due to automatic review settings June 4, 2026 16:45
@vercel

vercel Bot commented Jun 4, 2026

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
isolate-ui Ignored Ignored Preview Jun 4, 2026 4:51pm

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Updates the AI Orchestrator’s Ambiguity Mesh Router prompt so generic /query-style messages (prefixed with @isolate-) can be classified to the most appropriate specialist persona instead of defaulting to null, and adds unit tests to validate the new routing behavior and prevent prompt regressions.

Changes:

  • Expanded MESH_SYSTEM_PROMPT with persona domain descriptions and inference guidance for @isolate- generic queries.
  • Exported MESH_SYSTEM_PROMPT to enable direct prompt-constant testing.
  • Added new unit tests covering inferred routing for generic queries plus basic prompt-content validations.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
libs/ai-orchestrator/src/orchestrator/mesh-router.ts Exports and updates the mesh router system prompt to support best-fit persona inference for @isolate- generic queries.
libs/ai-orchestrator/src/tests/mesh-router.spec.ts Adds inference-focused test cases and prompt-constant validation tests.

Comment thread libs/ai-orchestrator/src/orchestrator/mesh-router.ts Outdated
Comment thread libs/ai-orchestrator/src/__tests__/mesh-router.spec.ts Outdated
Address review feedback:
1. Update MESH_SYSTEM_PROMPT to explicitly state that inference only
   applies to messages starting with @isolate-, preventing unintended
   mesh jumps for ordinary in-thread questions without explicit persona tags.
2. Change 'best-fit' to 'ONLY' in the keyword validation test to clarify
   the restricted scope.
3. Strengthen domain description test to check for actual bullet prefixes
   ('- po:', etc.) instead of loose substring matching.
@SteveJRobertson SteveJRobertson merged commit 4337ec5 into main Jun 4, 2026
6 checks passed
@SteveJRobertson SteveJRobertson deleted the 142-improve-mesh-router-classification branch June 4, 2026 16:53
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.

feat: improve mesh router classification for inferred/generic queries

2 participants