Inference Operating Mode: which Task call sites gate on inference_enabled, and how each fails
This guide covers how the inference_enabled Configuration Schema flag (engine/inference_operating_mode.py) reaches, or deliberately doesn't reach, every Task in this codebase that can call InferenceClient or EmbeddingClient. It keeps the declared-mode versus transient-failure boundary in one place. Section 3 traces what a genuine call failure does in the Trigger Dispatch Queue.
Two states are kept separate throughout:
| State | Meaning | What happens |
|---|---|---|
inference_enabled=false |
A declared, known absence of an inference endpoint at this site. | Every gated Task call site below skips its model or embedding call entirely and returns a deterministic, structured fallback. It is never a failure, never dead-lettered, and never logged as an error. |
inference_enabled=true (the default) and a genuine call failure |
An unexpected outage on a site that believes it has a working endpoint. | The flag does not affect this path. The Task raises its own domain-specific error (CaseSummarizationError, PlaybookDraftingError and so on). Only the first state gets a fallback, by design. |
1. Every gated call site
Ten classes carry an inference_enabled: bool = True constructor argument:
| Class | Module | Fallback when false |
|---|---|---|
CaseTriage |
engine/case_triage.py |
Structured-facts-only summary (_build_fallback_summary). |
ShiftHandoffTask |
engine/shift_handoff.py |
Reuses draft_narrative's shared fallback shape. |
TimeRangedActivityNarrativeTask |
engine/time_ranged_activity_narrative.py |
Same shared fallback shape as ShiftHandoffTask. |
PlaybookDrafter |
engine/playbook_drafting.py |
Classification falls back to GENERIC_STRATEGY. Drafting falls back to the raw ingested text. |
PlaybookAnswerer |
engine/playbook_answer.py |
INFERENCE_DISABLED_MESSAGE, grounded=False. Retrieval itself is skipped too, since it needs an embedding call. |
CasePrecedentRetriever |
engine/case_precedent_retrieval.py |
[], the same empty result an unconfigured retriever already returns. |
OrderNarrativeTask |
engine/order_narrative.py |
Structured-facts-only narrative (OrderTrail and Genealogy dispatch alike). |
OrderStatusQueryTask |
engine/order_status_query.py |
The abnormal-reasoning append only. The normal-status branch never called inference to begin with. |
InventoryShortageExplainerTask |
engine/inventory_shortage.py |
The explanation only. The peer WIP correlation query still runs either way. |
IngestionSink |
engine/document_ingestion.py |
Nothing is embedded. Items are held, not dropped, and ingested once the Node runs with inference enabled (see retrieval-ingestion-pipeline.md). engine/document_stack.py passes the flag through to it. |
Two more consumers take a required inference_enabled argument:
DocumentQueueWorker(engine/document_queue_worker.py): itsrun_oncereturns without claiming a row when the flag is false.- The claim-drafting
build_drafter(engine/instruction_claim_drafting.py): it loads no naming prompt when the flag is false.
Call sites that need no gate
Two real call sites were checked and confirmed to need no gate. Each is verified by a grep-backed regression test, not just left alone by assumption:
ReconciliationTask(engine/identity_resolution.py) is a reference-ID lookup plus a merge and save, with no model or embedding call anywhere in it. The test istests/test_identity_resolution.py::test_reconciliation_task_has_no_inference_client_dependency.build_variance_data_point(engine/costing_variance.py, the Costing Milestone variance explainer's live-cost lookup) is a Communication Interface peer query plus arithmetic. Its narrative step has always beenCaseTriage, already gated. The test istests/test_costing_variance.py::test_build_variance_data_point_has_no_inference_client_dependency.
2. How each gated Task actually runs, and why that matters for failure handling
The inference_enabled=false fallback path is identical everywhere: no call, so no failure is possible.
What differs, and what determines what happens on a genuine inference_enabled=true failure, is how each Task is invoked in a real node process. Three shapes exist today (engine/node_main.py and engine/erp_main.py), and they fail very differently:
| Shape | Consumers | On an uncaught exception |
|---|---|---|
Trigger Dispatch Queue (TriggerHandler, then dispatch_claimed_entry in engine/trigger_queue.py) |
CaseTriage only |
Try/Catch-wrapped. See section 3 for exactly what that does and doesn't catch. |
ScheduledTask (its own background thread, engine/node_runtime.py) |
ShiftHandoffTask (which holds CasePrecedentRetriever) |
Kills only that one background thread (see the _run_scheduled_task_loop docstring in engine/node_runtime.py). No trigger_queue row is involved at all. |
On-demand (.answer(), .explain(), .query() or .narrate() called directly: a point-of-use lookup, an incoming cross-node dialogue query, an event callback) |
PlaybookAnswerer, OrderStatusQueryTask, InventoryShortageExplainerTask, OrderNarrativeTask |
Whatever the direct caller does. There is no Trigger Dispatch Queue row and no ScheduledTask wrapper. |
PlaybookDrafter and TimeRangedActivityNarrativeTask are gated in code but have no construction call site in either entrypoint, so node_main.py and erp_main.py do not pass them the flag.
3. A genuine call failure does not dead-letter a queue row
A genuinely unreachable endpoint does not propagate through Try/Catch's unresponsive-service path to a dead-lettered Trigger Dispatch Queue row.
The real path for CaseTriage, the only gated consumer that runs through the Trigger Dispatch Queue, is:
CaseTriage._summarize_callcallsInferenceClient.call. It retries transport failures internally (its own 3-attempt escalating-temperature loop) and never raises. It reports failure throughCallOutcome.success=False.raise_if_failed(engine/inference.py) then raisesCaseSummarizationError. That is a plainKindredError, notUnresponsiveServiceFailure.dispatch_claimed_entrywraps the dispatched step in aTryCatch(engine/try_catch.py) that only catchesUnresponsiveServiceFailureandPromptCausedFailure.CaseSummarizationErrormatches neither, so it propagates on the very first attempt. This is the Pitfall already documented intrigger-dispatch-queue.md: "a genuine bug instep... propagates out ofdispatch_claimed_entryuncaught". No retry-then-give-up loop runs at theTryCatchlayer at all. The real retrying already happened, and already exhausted, one layer down insideCaseTriageitself.- The row is never resolved to
dead_lettered. It staysclaimed.dispatch_claimed_entry's outcome check (Outcome.SUCCEEDEDleads tomark_done, andOutcome.GAVE_UPorOutcome.EXHAUSTEDtomark_dead_lettered) never runs, because the exception leaveslog_try_catch_taskbefore returning. - The exception continues propagating out of
dispatch_claimed_entry, and from there out ofrun_trigger_dispatch_loopitself.
This is CaseTriage's behavior independent of the flag. inference_enabled=true is a pure no-op against the call path, and the call path has this gap.
It is verified by tests/test_inference_operating_mode.py::test_case_triage_dispatched_through_the_trigger_queue_with_endpoint_unreachable_is_unchanged. That test dispatches CaseTriage through a real TriggerQueue and dispatch_claimed_entry with an unreachable transport, and asserts exactly this: the exception propagates, and the row stays claimed.
Known limit: exhausted-retry domain errors are not translated into UnresponsiveServiceFailure at the dispatch boundary. Doing so would change error-handling semantics shared by every dispatch_claimed_entry caller. This section documents the behavior rather than altering it.
Pitfalls
-
A gate existing on a class doesn't mean it's wired into a real node. Check the table in section 2 before assuming
inference_enabled: falsein a site's config changes a given Task's runtime behavior.node_main.pyanderp_main.pythreadinference_is_enabled(config)into each of the seven real constructor call sites that exist today:CaseTriage,ShiftHandoffTask,CasePrecedentRetriever,PlaybookAnswerer,OrderStatusQueryTask,InventoryShortageExplainerTaskandOrderNarrativeTask.- This is proven by
tests/test_node_main.py::test_inference_disabled_config_wires_fallback_into_every_mes_construction_call_siteandtests/test_erp_main.py::test_inference_disabled_config_wires_fallback_into_every_erp_construction_call_site. Each builds a real runtime with a never-calledInferenceClientandEmbeddingClienttransport, so a still-live model or embedding call fails the test outright, rather than only checking each object's private attribute. PlaybookDrafterandTimeRangedActivityNarrativeTaskstay unwired, because no construction call site exists for either.
-
"Gated" and "protected by the Trigger Dispatch Queue's dead-letter guarantee" are unrelated claims. Only
CaseTriageruns throughdispatch_claimed_entryat all. AScheduledTaskor on-demand consumer's genuine inference failure was never going to dead-letter a queue row in the first place, gated or not, because there is no row to dead-letter. -
Don't assume every genuine call failure looks like
UnresponsiveServiceFailureorgave_up. Every gated Task raises its own domain-specific error on an exhausted retry budget:CaseSummarizationErrorPlaybookDraftingErrorPlaybookAnswerErrorOrderNarrativeErrorOrderStatusReasoningErrorInventoryShortageExplanationErrorShiftHandoffSummaryErrorTimeRangedActivityNarrativeError
None of these are Try/Catch's own vocabulary, so none of them trigger its retry-then-give-up and dead-letter machinery by themselves. Section 3 is what that means for the one call site where it matters.
Release: v0.11.0