conductor-oss/conductor · error · IllegalArgumentException

Unknown termination type: ${type}

Error message

Unknown termination type: ${type}

What it means

Thrown by TerminationCompiler.buildTerminationScript() when config.getType() is not one of the six supported termination condition types: 'text_mention', 'stop_message', 'max_message', 'token_usage', 'and', 'or'. The compiler dispatches on this type string in a switch expression; an unrecognized value hits the default branch.

Source

Thrown at agentspan/src/main/java/org/conductoross/conductor/ai/agentspan/runtime/compiler/TerminationCompiler.java:166

    }

    /**
     * Recursively build the JavaScript expression string for a given {@link TerminationConfig}.
     * Composite types (and/or) inline their sub-conditions directly into the generated script.
     *
     * @param config the termination configuration
     * @return a JavaScript IIFE string
     */
    public static String buildTerminationScript(TerminationConfig config) {
        String type = config.getType();
        return switch (type) {
            case "text_mention" -> buildTextMentionScript(config);
            case "stop_message" -> buildStopMessageScript(config);
            case "max_message" -> buildMaxMessageScript(config);
            case "token_usage" -> buildTokenUsageScript(config);
            case "and" -> buildCompositeScript(config, true);
            case "or" -> buildCompositeScript(config, false);
            default -> throw new IllegalArgumentException("Unknown termination type: " + type);
        };
    }

    // ----------------------------------------------------------------
    // Private builders for each termination type
    // ----------------------------------------------------------------

    private static String buildTextMentionScript(TerminationConfig config) {
        String textJs = JavaScriptBuilder.toJson(config.getText());
        boolean caseSensitive =
                config.getCaseSensitive() != null ? config.getCaseSensitive() : true;

        return JavaScriptBuilder.iife(
                "  var content = String($.result || '');"
                        + "  var text = "
                        + textJs
                        + ";"
                        + "  var caseSensitive = "

View on GitHub (pinned to cf7c3e4a8a)

Solutions

  1. Set type to one of: 'text_mention', 'stop_message', 'max_message', 'token_usage', 'and', 'or'.
  2. For composite conditions (AND/OR), also set the 'conditions' list with sub-TerminationConfig entries.
  3. Check for typos — e.g., 'max_messages' (plural) is wrong; use 'max_message' (singular).

Example fix

// before
TerminationConfig.builder().type("max_messages").maxMessages(10).build();
// after
TerminationConfig.builder().type("max_message").maxMessages(10).build();
Defensive patterns

Strategy: validation

Validate before calling

private static final Set<String> VALID_TERM_TYPES =
    Set.of("text_mention", "stop_message", "max_message", "token_usage", "and", "or");

void validateTerminationType(TerminationConfig config) {
    if (config.getType() == null || !VALID_TERM_TYPES.contains(config.getType())) {
        throw new IllegalArgumentException(
            "Unknown termination type: " + config.getType() + ". Valid: " + VALID_TERM_TYPES);
    }
}

Type guard

static boolean isValidTerminationType(String type) {
    return Set.of("text_mention", "stop_message", "max_message",
                  "token_usage", "and", "or").contains(type);
}

Try / catch

try {
    String script = TerminationCompiler.buildTerminationScript(config);
} catch (IllegalArgumentException e) {
    if (e.getMessage().contains("Unknown termination type")) {
        // fix the type string and retry
    }
    throw e;
}

Prevention

When it happens

Trigger: A TerminationConfig whose type field is null or an unrecognized string. For example type='message_count' instead of 'max_message', or type=null.

Common situations: Typo in the termination type string, using a termination type from a different framework's API, or leaving the type field unset. Common when termination configs are constructed from user input or templated configs with unfilled type fields.

Related errors


AI-assisted analysis of conductor-oss/conductor@cf7c3e4a8a (2026-08-14). Data as JSON: /api/errors/71a0add1ae7817ee. Report an issue: GitHub.