When it runs
TheScenarioOrchestrator._resolve_scenario_for_job resolution has
four tiers:
- Explicit pin —
metadata.scenario_idwins. Used by replay, admin tooling, and the chain primitive itself when re-dispatching. - Intent route mapping —
metadata.intent_routelooked up in each scenario’s declaredintent_routes. - Tier-3: classifier default —
metadata.kind == "task"with no higher-priority pin routes here. This is the path the command-widget Task card sends. - Orchestrator default —
CEREBRUM_DEFAULT_SCENARIOorcode_build.
intent_route. Leaving
intent_routes: [] keeps it from claiming any route name and prevents
it from recommending itself as a target.
Architecture
Two-level shape
classify is a pure prompt level. It synthesizes every
classifier-eligible scenario into the prompt’s AVAILABLE SCENARIOS
block:
schema intra-verifier catches malformed envelopes; the level
retries once. If both attempts fail, the orchestrator’s
classifier-failure safety net chains to quick_qa.
disambiguate only runs on the low-confidence branch. The first model
turn emits an ask_user envelope carrying an enum schema; the FE
renders this as a button panel inside the task modal; the user clicks
their pick; the resume folds the answer back; the second turn emits
the final chosen_intent_route JSON.
Catalog construction
The orchestrator builds the classifier catalog once at startup in__post_init__:
examples: block. That keeps admin/debug scenarios
(code_build_strict, parallel_review_demo) out of the catalog
without a separate flag.
The catalog is threaded into the LangGraph state as
state["classifier_catalog"] so the prompt builder reads it without
needing to touch the orchestrator directly.
Chain primitive
ScenarioResult carries two new fields:
chained_intent_route: str | Nonechain_reason: str | None
output_parsed contains a chosen_intent_route
field, the runner promotes it onto top-level state. The orchestrator’s
run() reads this after the compiled-graph invocation, builds a new
payload pinned to the target scenario via metadata.scenario_id,
bumps _chain_depth, emits a scenario_chained event, and recurses.
MAX_CHAIN_DEPTH = 3 caps the chain depth. The classifier counts as
one hop, so composite follow-ups have two more slots before the cap.
CLASSIFIER_FALLBACK_SCENARIO_ID = "quick_qa" is the safety net the
orchestrator chains to when:
- the classifier emitted no
chained_intent_routeAND itsaborted_reasonis set or output is empty, OR - the classifier emitted a
chosen_intent_routethat isn’t a loaded scenario id (hallucination).
Files
knowledge-hub/scenarios/intent_classifier.yaml— the scenario YAMLworker/worker/graph/scenarios/prompts.py—intent_classifier_route+intent_classifier_disambiguateworker/worker/graph/scenarios/orchestrator.py— tier-3 rule, chain loop, classifier-failure safety net (MAX_CHAIN_DEPTH,INTENT_CLASSIFIER_SCENARIO_ID,CLASSIFIER_FALLBACK_SCENARIO_ID)worker/worker/graph/scenarios/runners.py— auto-populatesoutput_parsedon JSON levels; promoteschosen_intent_routeto stateworker/worker/graph/scenarios/state.py—chained_intent_route,chain_reason,classifier_catalogfields onScenarioStateapps/frontend/components/layout/footer/ask-user-enum-panel.tsx— the FE button-panel renderer
Configuration
Locked decisions (2026-05-18):| Setting | Value | Where |
|---|---|---|
| Confidence threshold | 0.7 | intent_classifier.yaml when: clause on the classify → __end__ edge |
| Classifier-failure fallback | quick_qa | orchestrator.CLASSIFIER_FALLBACK_SCENARIO_ID |
| Chain depth cap | 3 | orchestrator.MAX_CHAIN_DEPTH |
| Model tier | free-tier (Ollama / equivalent) with paid fallback | model_constraint: { allow: ["free:*"], fallback_outside_allow: true } |
Future composition
Oncechained_intent_route is a first-class field, scenarios chain
arbitrarily. Examples this primitive unlocks:
- incident_response — classify alert → fetch logs (aws_pulse-like)
→ diagnose (LLM) → propose fix → chain to
github_pr_fixif the user approves. - monitoring_digest — aws_pulse + vercel_status + github_open_prs → synthesize a single morning brief.
- ambient_oncall — long-running scenario that periodically chains to whichever specialist scenario the latest alert maps to.