{"record":{"id":"71a0add1ae7817ee","repo":"conductor-oss/conductor","slug":"unknown-termination-type-type","errorCode":null,"errorMessage":"Unknown termination type: ${type}","messagePattern":"Unknown termination type: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":400,"severity":"error","filePath":"agentspan/src/main/java/org/conductoross/conductor/ai/agentspan/runtime/compiler/TerminationCompiler.java","lineNumber":166,"sourceCode":"    }\n\n    /**\n     * Recursively build the JavaScript expression string for a given {@link TerminationConfig}.\n     * Composite types (and/or) inline their sub-conditions directly into the generated script.\n     *\n     * @param config the termination configuration\n     * @return a JavaScript IIFE string\n     */\n    public static String buildTerminationScript(TerminationConfig config) {\n        String type = config.getType();\n        return switch (type) {\n            case \"text_mention\" -> buildTextMentionScript(config);\n            case \"stop_message\" -> buildStopMessageScript(config);\n            case \"max_message\" -> buildMaxMessageScript(config);\n            case \"token_usage\" -> buildTokenUsageScript(config);\n            case \"and\" -> buildCompositeScript(config, true);\n            case \"or\" -> buildCompositeScript(config, false);\n            default -> throw new IllegalArgumentException(\"Unknown termination type: \" + type);\n        };\n    }\n\n    // ----------------------------------------------------------------\n    // Private builders for each termination type\n    // ----------------------------------------------------------------\n\n    private static String buildTextMentionScript(TerminationConfig config) {\n        String textJs = JavaScriptBuilder.toJson(config.getText());\n        boolean caseSensitive =\n                config.getCaseSensitive() != null ? config.getCaseSensitive() : true;\n\n        return JavaScriptBuilder.iife(\n                \"  var content = String($.result || '');\"\n                        + \"  var text = \"\n                        + textJs\n                        + \";\"\n                        + \"  var caseSensitive = \"","sourceCodeStart":148,"sourceCodeEnd":184,"githubUrl":"https://github.com/conductor-oss/conductor/blob/cf7c3e4a8adfb158be778ab1ec525323c363cd3a/agentspan/src/main/java/org/conductoross/conductor/ai/agentspan/runtime/compiler/TerminationCompiler.java#L148-L184","documentation":"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.","triggerScenarios":"A TerminationConfig whose type field is null or an unrecognized string. For example type='message_count' instead of 'max_message', or type=null.","commonSituations":"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.","solutions":["Set type to one of: 'text_mention', 'stop_message', 'max_message', 'token_usage', 'and', 'or'.","For composite conditions (AND/OR), also set the 'conditions' list with sub-TerminationConfig entries.","Check for typos — e.g., 'max_messages' (plural) is wrong; use 'max_message' (singular)."],"exampleFix":"// before\nTerminationConfig.builder().type(\"max_messages\").maxMessages(10).build();\n// after\nTerminationConfig.builder().type(\"max_message\").maxMessages(10).build();","handlingStrategy":"validation","validationCode":"private static final Set<String> VALID_TERM_TYPES =\n    Set.of(\"text_mention\", \"stop_message\", \"max_message\", \"token_usage\", \"and\", \"or\");\n\nvoid validateTerminationType(TerminationConfig config) {\n    if (config.getType() == null || !VALID_TERM_TYPES.contains(config.getType())) {\n        throw new IllegalArgumentException(\n            \"Unknown termination type: \" + config.getType() + \". Valid: \" + VALID_TERM_TYPES);\n    }\n}","typeGuard":"static boolean isValidTerminationType(String type) {\n    return Set.of(\"text_mention\", \"stop_message\", \"max_message\",\n                  \"token_usage\", \"and\", \"or\").contains(type);\n}","tryCatchPattern":"try {\n    String script = TerminationCompiler.buildTerminationScript(config);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"Unknown termination type\")) {\n        // fix the type string and retry\n    }\n    throw e;\n}","preventionTips":["Use the exact lowercase type strings from the TerminationConfig Javadoc.","Define termination type strings as constants to avoid typos.","Validate termination configs in unit tests before deployment."],"tags":["termination","config-validation","agentspan"],"backgroundTag":null,"analyzedSha":"cf7c3e4a8adfb158be778ab1ec525323c363cd3a","analyzedAt":"2026-08-14T03:33:19.897Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}