ComfyUI Node

AZAll Conditional Router

Split the graph on a keyword — or catch LLM errors

By cronos3k·Created 5 months ago·Updated 5 months ago· 0
AZAll Conditional Router
    • matched
    • unmatched
    text
    pattern
    use_regexfalse
    case_sensitivefalse

    The pack's "if this text matches, go this way" node. AgentAZAll_ConditionalRouter tests a string against a pattern - a plain substring by default, or a full regex if you flip the switch - and sends the text out the matched or unmatched output accordingly. It's the closest thing AgentAZAll has to a branch statement, and its star turn is error handling: the LLM node returns failures as strings starting with [LLM_ERROR], and the RAG demo routes exactly those to an error display while letting real responses flow to the success path.

    This is the node that keeps a fragile multi-agent workflow from dying on a flaky model call. Instead of a hard crash, you get a graceful fork.

    How it works

    Give it text and pattern. If the pattern matches, the text exits through matched and unmatched is empty; if not, the reverse. Three behaviors shape it: an empty pattern always matches (text goes to matched); matching is case-insensitive by default (flip case_sensitive to change that); and with use_regex on, the pattern is compiled and searched as a regular expression - a malformed regex is caught and treated as no-match rather than crashing the workflow.

    The inputs that matter

    • text (required, forceInput) - the string to test. Wire it from the LLM's response, Recall's results, or any STRING.
    • pattern (required) - what to look for. For catching LLM errors: LLM_ERROR. For topic routing: a keyword per branch.
    • use_regex - false = plain substring; true = regular expression.
    • case_sensitive - false by default; set true if llm_error shouldn't match LLM_ERROR.

    Two outputs, matched and unmatched - the full input text on exactly one of them, empty on the other. Wire each into a different branch of the graph (e.g., error display vs. success path).

    Installing it

    In cronos3k/comfyui-agentazall - Manager search "AgentAZAll", or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/cronos3k/comfyui-agentazall.git
    pip install "agentazall>=1.0.13"
    # restart ComfyUI
    

    No models, no keys.

    Common issues

    The classic mistake is treating it like a content filter when it's really a prefix-or-substring switch - it doesn't parse or transform anything, it just routes the whole string. If you want [LLM_ERROR] caught reliably, put the LLM node directly upstream; other text passing through that happens to contain the word "error" will also match, so keep patterns specific. Regex users: remember the search is re.search, not full-match, so ^LLM_ERROR anchors work but patterns assume substring semantics. And like every node here, it re-runs each queue execution, so the route reflects the latest text every time - which is exactly the behavior a live error-handling branch needs.

    CategoryAgentAZAll/Utility

    Inputs (4)

    NameTypeDefaultDescription
    textSTRING
    patternSTRING
    use_regexoptBOOLEANfalse
    case_sensitiveoptBOOLEANfalse

    Outputs (2)

    NameTypeDescription
    matchedSTRING
    unmatchedSTRING