Loading

Agentforce : Use before_reasoning for Mandatory Logic When Hyper-Classifier Is Enabled

Publiceringsdatum: Aug 11, 2026
Beskrivning

When using Hyper-Classifier in an Agentforce agent, mandatory logic configured through state-based routing actions might not execute before the agent selects a topic.

The Hyper-Classifier runs as a pre-orchestration step. It evaluates the user's utterance and routes the request to the topic that is most semantically relevant. This routing decision occurs before the agent evaluates state-based routing conditions.

For example, an agent might have a User Verification topic with a condition such as:
RunningUserValidated == False

If the user asks a business-related question, such as "Give me a summary of this account," Hyper-Classifier might select the relevant business topic instead of the User Verification topic because the User Verification topic is not semantically related to the request.

In this situation, the RunningUserValidated == False condition is evaluated later and does not force the User Verification topic to execute before the business topic. As a result, logic that was expected to run as a mandatory precondition might be skipped.

This behavior is expected platform behavior and is not specific to a particular agent. Hyper-Classifier routing and state-based routing conditions operate in separate execution phases.

Symptoms

When this issue occurs, the agent might intermittently fail to complete a request and display:

"I apologize, but I encountered an unexpected error."

You might also notice:

  • The issue occurs intermittently rather than for every request.
  • Required user or context variables might not be populated.
  • A topic or subagent that depends on those variables might fail.
  • The behavior can vary depending on the user's utterance and the topic selected by Hyper-Classifier.
Lösning

For logic that must execute unconditionally on every turn before topic selection, use the before_reasoning lifecycle hook.

Move mandatory logic, such as populating EndUserId and EndUserName, into the before_reasoning hook on agent_router.

The before_reasoning hook executes before Hyper-Classifier makes its routing decision. This ensures that mandatory logic runs before any topic or subagent is selected, regardless of which topic Hyper-Classifier chooses.

Recommended execution flow:

before_reasoning → Mandatory initialization/pre-processing → Hyper-Classifier → Topic selection → Downstream reasoning

Important

  • Hyper-Classifier makes its routing decision before state-based routing conditions are evaluated.
  • State-based routing conditions cannot be relied upon to enforce mandatory preconditions when Hyper-Classifier is enabled.
  • Use before_reasoning for logic that must execute on every turn.
  • Use state-based routing conditions for conditional routing logic that does not need to execute before Hyper-Classifier routing.
  • Do not rely on a semantically unrelated topic, such as User Verification, to enforce mandatory logic before Hyper-Classifier selects a topic.
  • Populate variables required by downstream topics or subagents before those topics execute.


Example

If an agent must populate EndUserId and EndUserName before any downstream processing, place that logic in before_reasoning rather than in a state-gated routing action.

This ensures the required user variables are populated on every turn before Hyper-Classifier selects a topic.
Using before_reasoning for mandatory logic provides consistent execution regardless of which topic is selected for the user's request.

Knowledge-artikelnummer

005390902

 
Laddar
Salesforce Help | Article