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
- 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).
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
- 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.
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
- Composite termination (${isAnd ? "and" : "or"}) must have at
- Unknown termination type in composite: ${type}
- Composite termination must have at least one sub-condition
- Unknown termination type in nested composite: ${type}
- SWARM handoff type must be on_tool_result, on_text_mention,
AI-assisted analysis of conductor-oss/conductor@cf7c3e4a8a (2026-08-14).
Data as JSON: /api/errors/71a0add1ae7817ee.
Report an issue: GitHub.