Matrix Coder — Intent Detection & Routing

How the pre_llm_call hook decides whether a specialist persona activates — every turn, local heuristics only, no extra LLM call

PRECEDENCE explicit trigger implicit inference ▸ no-op Every conversation turn pre_llm_call → _inject_persona cron or sys-preamble? yes inject nothing skip / bail early no starts with `matrix`? DECISION 1 — explicit trigger yes — EXPLICIT parse_trigger( message ) grammar: matrix <role> [<lens>] [@<domain>] [:] <goal> role ∈ {review, executor, explore, plan, debug, test, verify, simplify} OR workflow ∈ {ralph, autopilot, ultrawork, ultraqa} lens (review only) ∈ {security, code, api, performance, quality, deps} @domain ∈ {frontend, backend-api, data-db, infra-cli, plugin-skill-authoring} MATRIX — persona injected explicit always wins · role + optional domain pack composed into THIS turn's context OUTCOME A no clear any stale persona from prior turn coding intent? DECISION 2 — has_coding_intent() no intent inject nothing ordinary chat → Hermes OUTCOME B yes CODING SIGNAL — true when ANY: · file path / code extension (.py .tsx .sql…) · starts with role word + technical term · coding term + (action term OR ? OR starts with is/does/why/where/how) bail → "handle it directly" / "let Hermes do it" · none of above → None (no coding intent) infer role · lens (review) · @domain priority: review→verify→debug→test→simplify→explore→plan→executor trivial request? DECISION 3 — implicit_intake_gate() yes — DIRECT DIRECT verdict recommend only · no persona "Efficient for Hermes to handle…" OUTCOME C TRIVIAL if ALL: · role ∈ {executor, simplify} · mechanical (typo, rename, comment format, README) · ≤ 10 words AND NOT security · else → MATRIX verdict no MATRIX — persona injected inferred specialist persona for the route composed into THIS turn's context OUTCOME D ROUTE NAME FORMAT role · review:lens · role@domain · review:lens@domain e.g. debug · review:security@backend-api · plan@frontend POST-TURN — post_llm_call hook: _clear_persona() Active persona cleared after every turn. Persona is pure TEXT injected into context — no subagent/persona API. Re-asserted each turn from scratch. Legend persona active (MATRIX verdict) DIRECT recommendation no-op / inject nothing guard / early bail decision diamond core/intent_gate.py · has_coding_intent() · parse_trigger() · implicit_intake_gate() core/intake.py · _inject_persona() pre_llm_call · _clear_persona() post_llm_call

MATRIX verdict (persona active)

  • · Outcome A — user wrote matrix review:security@backend-api fix the auth flow
  • · Outcome D — implicit: message contains a .tsx path + "fix" keyword
  • · Role + optional lens + optional @domain compose the specialist persona
  • · Persona text is injected into the current turn's LLM context
  • · Unknown first token → role defaults to review; rest is the goal

DIRECT recommendation (Outcome C)

  • · role ∈ {executor, simplify} AND mechanical task (typo, rename, comment, format, README)
  • · Message is ≤ 10 words AND not security-sensitive
  • · Injects a visible tip only — no specialist persona
  • · User can override: "invoke Matrix Coder anyway, or let Hermes do it?"

No-op paths

  • · Cron session or system-preamble → bail immediately (early guard)
  • · has_coding_intent() returns None → ordinary chat passes through to Hermes
  • · "handle it directly" / "let Hermes do it" phrases also short-circuit to None
  • · Post-turn: _clear_persona() always runs — no persona leaks between turns

Route name format

  • · role — e.g. debug
  • · review:lens — e.g. review:security
  • · role@domain — e.g. plan@frontend
  • · review:lens@domain — e.g. review:api@backend-api
  • · Domains: frontend, backend-api, data-db, infra-cli, plugin-skill-authoring