Creates an instance of LLMDecision.
Optional API key for BaseDecision/BaseModel compatibility.
ID of the MJAIPrompt entity to execute.
User context for prompt execution.
OptionalExecutionThe decision's AIPromptExecutionScope — configuration, runtime API keys and credential
scope — which the chat prompt runs under. AIDecisionRunner sets it from the decision's params.
Without it the chat prompt carried only the user, so it answered on the platform's keys even
when the decision itself was restricted to the caller's.
OptionalParentThe MJ: AI Prompt Runs row this decision is recorded under. When set, the chat prompt's run
is created as its child (ParentID), so the chat call's cost rolls up to the decision's run.
AIDecisionRunner sets it to its own run before it calls the driver.
ProtectedapiOnly sub-classes can access the API key
Gets the configured prompt ID.
Executes a typed decision request across one or more questions about a given state. This method wraps driver execution with input validation, output verification, execution timing, and structured error handling. It never throws.
Decision request parameters including state, questions, and model.
A Promise resolving to a DecisionResult.
ProtectedDoExecutes the decision by calling the AI prompt and mapping answers.
Parameters for the decision including State and Questions.
DecisionResult containing answers or error details.
ProtectedValidateValidates driver output DecisionResult against the requested questions.
Original decision request parameters.
Result returned by the driver.
An array of error descriptions, empty if valid.
ProtectedValidateValidates input DecisionParams against the decision contract.
Parameters to validate.
An array of error descriptions, empty if valid.
Driver that answers typed decision questions with a chat LLM through an MJ prompt. It is the fallback
BaseDecisiondriver: everything downstream can be written againstBaseDecisionbefore a native decision model is configured. Unlike a native driver it must parse, because a chat model can return malformed JSON.The prompt receives three template variables:
state: the decision state, as-is when it is a string, otherwise as indented JSON;questions: JSON mapping each question key to{ kind, instructions, options?, levels? };outputFormat: the reply's shape as JSON, with every option or level listed and an unquoted placeholder where each number goes.It must reply with one JSON object with the same keys: a number for a Likelihood, and an object mapping every option value (Choice) or level name (Score) to a number. Choice and Score distributions are normalised here, so
BaseDecision.Decidecan validate them strictly. A value that is present but is not a usable number fails the question; it is never read as 0.Registered with ClassFactory under BaseDecision with key 'LLMDecision'.