Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
79a2891
Add batch, outline, save and run-control tools to the agent MCP bridge
cincrement Nov 9, 2026
e2f8bee
Extend the agent MCP bridge: run results, text round-trip, lifecycle,…
cincrement Nov 9, 2026
0e68abc
Make headless agent plans usable and document agent settings
cincrement Nov 9, 2026
6d027c0
Let agents read full requests and responses of samples
cincrement Nov 9, 2026
1972463
Point the AI repair and request prompts at the new bridge tools
cincrement Nov 9, 2026
d5d62f1
Store agent variables under the Shared Profile
cincrement Nov 9, 2026
56a395e
Drop AI Repair file mode; keep a thread group copy and add Revert
cincrement Nov 9, 2026
27a0273
Stabilise two HTTP tests that fail on slow macOS CI runners
cincrement Nov 10, 2026
9313888
Tolerate the reactor-wait fallback in the HTTP/2 stop test instead of…
cincrement Nov 10, 2026
2b9c1da
Let the AI Repair launcher's initial analysis find its thread group
cincrement Nov 10, 2026
8197ae8
Cut AI Repair turns and context: small validation summary, recording …
cincrement Nov 10, 2026
8b27700
Trim AI Repair further: verdicts in the packet, leaner prompt, fewer …
cincrement Nov 10, 2026
27757da
AI Repair leftovers: repeat validation, packet size, names, dialog path
cincrement Nov 10, 2026
fab9456
get_sample accepts common part names; the audit marks cache validator…
cincrement Nov 10, 2026
f16c521
Do not carry a validation summary baseline across AI runs
cincrement Nov 10, 2026
488424b
Stop pointing Codex at the breaktest-jmeter-repair skill
cincrement Nov 10, 2026
fd410d5
Shorten focused AI edits: settings at default are named, prompt skips…
cincrement Nov 10, 2026
3160765
Batch for-each over matching nodes, and table rows that append or upsert
cincrement Nov 10, 2026
29b2b6c
Keep the three-argument AgentElementCatalog.configured for Java callers
cincrement Nov 10, 2026
a04fa0f
Wait for settled focus in ParameterCompletionTableTest
cincrement Nov 10, 2026
922bfae
Fix agent plan routing, relative files, and HTTP query handling
cincrement Nov 10, 2026
f4a5cd6
Fix agent throughput timing and clear stale validation evidence
cincrement Nov 10, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions bin/jmeter.properties
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,9 @@
# Local AI tool selected by default in the start dialog: codex, claude, cursor,
# gemini, pi, opencode, or copilot.
#breaktest.ai.tool=codex
# Edit surface selected by default in the start dialog: gui or non-gui.
# gui uses live GUI edit tools; non-gui (shown as JMX file mode) creates an
# immutable backup, repairs the active saved JMX, and reloads that file afterward.
#breaktest.ai.edit_surface=gui
# Whether the start dialog's "Keep a copy of the thread group" box starts ticked. The copy is
# disabled and shows the thread group as it was before the AI run.
#breaktest.ai.keep_thread_group_copy=true
# Optional shared working directory for local AI tools. Tool-specific cwd settings
# below take precedence. Defaults to the open test plan directory, then JMETER_HOME.
#breaktest.ai.cwd=
Expand All @@ -195,6 +194,13 @@
# Absolute path to the BreakTest agent bridge used by local AI tools. Defaults to
# JMETER_HOME/bin/breaktest-agent-tool, then breaktest-agent-tool on PATH.
#breaktest.agent.tool=

# What a connected coding agent (MCP bridge) may do in this BreakTest:
# read = inspect only; edit = also change and validate the plan; run = also start real test runs
#breaktest.agent.permissions=run

# Ask for confirmation in the window before an agent starts a real test run
#breaktest.agent.confirm_run=true
# Maximum runtime in seconds of a JSR223 Ask AI request before the AI tool is stopped.
#breaktest.jsr223.ai.timeout_seconds=600
# Optional shared custom predefined-correlation catalog. Relative paths resolve
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,19 @@ static Instructions resolveInstructions(boolean windows) {
+ "` using your file-editing capability, then run `" + command
+ " <tool-name> --arguments-file " + argumentsPath
+ "`; overwrite that file before every bridge call",
"First write `{\"level\":\"info\",\"message\":\"Starting AI Auto Scripting\"}` to `"
+ argumentsFile.toAbsolutePath() + "`, then run `" + command
"The start is already announced. Report later milestones by writing "
+ "`{\"level\":\"info\",\"message\":\"...\"}` to `"
+ argumentsFile.toAbsolutePath() + "`, then running `" + command
+ " agent_activity --arguments-file " + argumentsPath + "`");
}
return new Instructions(
command,
"run `" + command + " <tool-name> '<json-arguments>'`",
"First call `" + command
+ " agent_activity '{\"level\":\"info\",\"message\":\"Starting AI Auto Scripting\"}'`");
"run `" + command + " <tool-name> '<json-arguments>'`; for multi-item JSON, or JSON containing "
+ "quotes, pass `-` and a heredoc in the same shell call: `" + command
+ " <tool-name> - <<'JSON'`, the JSON on the following lines, then `JSON`",
"The start is already announced. Report later milestones with `" + command
+ " agent_activity '{\"level\":\"info\",\"message\":\"...\"}'`, in the same shell command as "
+ "the next tool call where possible");
}

static void deleteArgumentsFile() {
Expand All @@ -65,11 +69,12 @@ static void deleteArgumentsFile() {
}
}

static String harnessBootstrap(boolean codex, String toolDisplayName) {
if (codex) {
return "Use $breaktest-jmeter-repair when it is available. If the skill or native BreakTest MCP tools "
+ "are unavailable, do not search for them or stop; use the bundled bridge below immediately.";
}
/**
* The same for every tool, Codex included. Codex used to be pointed at an installed
* breaktest-jmeter-repair skill; this prompt is self-contained now, and a skill written for an
* older workflow only added tens of kilobytes of conflicting instructions to every request.
*/
static String harnessBootstrap(String toolDisplayName) {
return "This run uses " + toolDisplayName + ". Do not look for or invoke a breaktest-jmeter-repair skill "
+ "and do not require a registered BreakTest MCP server. Use the bundled bridge below as the "
+ "authoritative BreakTest tool interface.";
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@
final class AiPrompts {
static final String LIVE_GUI_REPAIR = "ai-prompt-live-gui-repair.txt";
static final String SPECIFIC_REQUEST = "ai-prompt-specific-request.txt";
static final String FILE_BACKED_REPAIR = "ai-prompt-file-backed-repair.txt";
static final String USER_INSTRUCTIONS = "ai-prompt-user-instructions.txt";
/** Appended to the repair prompt only for a thread group that has WebSocket samplers. */
static final String WEBSOCKET_SECTION = "ai-prompt-websocket.txt";
/** Appended to the repair prompt only when the user gave instructions, which may ask to build something. */
static final String GENERATION_SECTION = "ai-prompt-generation.txt";
static final String RUN_OPTIONS = "ai-prompt-run-options.txt";

private static final String FRAGMENTS = "ai-prompt-fragments.properties";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import java.util.function.Consumer;
import java.util.function.Function;

import org.apache.jmeter.ai.AgentRunStats;
import org.apache.jmeter.control.Controller;
import org.apache.jmeter.control.ForkController;
import org.apache.jmeter.control.ForkController.ErrorAction;
Expand Down Expand Up @@ -2611,6 +2612,9 @@ private void notifyListeners(List<SampleListener> listeners, SampleResult result

private void notifyListeners(List<SampleListener> listeners, SampleResult result, int metadataRequirements,
boolean transaction, SampleResult startedSample) {
if (AgentRunStats.isEnabled()) {
AgentRunStats.record(result, transaction);
}
if (needsJMeterVariables(metadataRequirements)) {
setJMeterVariables(result, snapshotVariables(threadVars));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ public class AgentDynamicValueAnalyzer(
add(
"credential",
literal,
"Hard-coded credential-like value in request field '$fieldName'; move it to a top-level User Defined Variable and replace every occurrence.",
"Hard-coded credential-like value in request field '$fieldName'; move it to a shared User Defined Variable and replace every occurrence.",
)
}
for (match in QUERY_ID_REGEX.findAll(value)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public object AgentElementCatalog {
"choices" to (
property.propertyType.enumConstants?.map { (it as Enum<*>).name }
?: (property.getValue("tags") as? Array<*>)?.toList()
?: modeConstants(element.javaClass, property)
),
"acceptsExpression" to acceptsString(element, property)
)
Expand All @@ -83,11 +84,37 @@ public object AgentElementCatalog {
)
}

/**
* Allowed values of a plain String "...Mode" setting, from the class's own constants: delayMode
* takes DELAY_FIXED, DELAY_RANDOM and so on. Without them an agent has to guess the spelling.
*/
private fun modeConstants(type: Class<*>, property: PropertyDescriptor): List<String>? {
if (property.propertyType != String::class.java || !property.name.endsWith("Mode")) return null
val prefix = property.name.removeSuffix("Mode").replace(Regex("([a-z])([A-Z])"), "$1_$2").uppercase() + "_"
return generateSequence(type as Class<*>?) { it.superclass }
.flatMap { it.declaredFields.asSequence() }
.filter {
java.lang.reflect.Modifier.isStatic(it.modifiers) && java.lang.reflect.Modifier.isPublic(it.modifiers) &&
it.type == String::class.java && it.name.startsWith(prefix)
}
.mapNotNull { runCatching { it.get(null) as? String }.getOrNull() }
// Property keys share the prefix but are not values.
.filter { '.' !in it }
.distinct().toList().takeIf { it.isNotEmpty() }
}

private fun acceptsString(element: TestElement, property: PropertyDescriptor): Boolean =
runCatching { element.javaClass.getMethod(property.writeMethod.name, String::class.java) }.isSuccess

/** Return a fully configured clone; failed setters never partially mutate the live element. */
public fun configured(element: TestElement, values: JsonNode, tables: JsonNode? = null): TestElement {
// Java callers (protocol module tests) use the three-argument form.
@JvmOverloads
public fun configured(
element: TestElement,
values: JsonNode,
tables: JsonNode? = null,
tableMode: String? = null,
): TestElement {
require(values.isObject) { "properties must be an object" }
val copy = (element.clone() as TestElement).also(TestBeanHelper::prepare)
val descriptors = properties(copy).associateBy { it.name }
Expand Down Expand Up @@ -125,7 +152,7 @@ public object AgentElementCatalog {
property.writeMethod.invoke(copy, converted)
persistBeanProperty(copy, property, converted)
}
if (tables != null) AgentElementTables.configure(copy, tables)
if (tables != null) AgentElementTables.configure(copy, tables, AgentElementTables.Mode.of(tableMode))
return copy
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import com.fasterxml.jackson.databind.JsonNode
import org.apache.jmeter.config.Argument
import org.apache.jmeter.config.Arguments
import org.apache.jmeter.testelement.TestElement
import org.apache.jmeter.testelement.property.CollectionProperty

/** Adapters for native table models. Protocol types are resolved only when installed, avoiding a core dependency. */
internal object AgentElementTables {
Expand All @@ -35,7 +36,8 @@ internal object AgentElementTables {

private fun rowTypes(element: TestElement): Map<String, String> = when {
isType(element, WS_CONNECT) || isType(element, HEADER_MANAGER) -> mapOf("headers" to HEADER)
isType(element, HTTP_SAMPLER) -> mapOf("arguments" to HTTP_ARGUMENT)
// A request owns its headers; they are not a child Header Manager.
isType(element, HTTP_SAMPLER) -> mapOf("arguments" to HTTP_ARGUMENT, "headers" to HEADER)
element is Arguments -> mapOf("arguments" to Argument::class.java.name)
else -> emptyMap()
}
Expand All @@ -49,17 +51,90 @@ internal object AgentElementTables {
)
}

fun configure(element: TestElement, tables: JsonNode) {
/** Current rows of each supported table, reduced to the fields that carry a value. */
fun read(element: TestElement): Map<String, List<Map<String, Any?>>> = rowTypes(element).keys.associateWith { rows(element, it) }

private fun rows(element: TestElement, table: String): List<Map<String, Any?>> =
rowElements(element, table).map { row ->
fun call(method: String): Any? = runCatching { row.javaClass.getMethod(method).invoke(row) }.getOrNull()
mapOf(
"name" to call("getName"), "value" to call("getValue"),
"alwaysEncoded" to call("isAlwaysEncoded")?.takeIf { it == true },
"useEquals" to call("isUseEquals")?.takeIf { it == false },
).filterValues { it != null }
}

private fun rowElements(element: TestElement, table: String): List<TestElement> {
val getter = when {
table == "headers" && isType(element, HTTP_SAMPLER) -> "getNativeHeaders"
table == "headers" -> "getHeaders"
else -> "getArguments"
}
val container = if (element is Arguments) element else runCatching { element.javaClass.getMethod(getter).invoke(element) }.getOrNull()
val items: List<Any?> = when (container) {
is Arguments -> container.iterator().asSequence().map { it.objectValue }.toList()
is CollectionProperty -> container.iterator().asSequence().map { it.objectValue }.toList()
is Iterable<*> -> container.toList()
else -> emptyList()
}
return items.filterIsInstance<TestElement>()
}

/** How supplied rows combine with the rows a table already has. */
enum class Mode {
/** The supplied rows become the table. */
REPLACE,

/** The supplied rows are added after the existing ones. */
APPEND,

/** A supplied row replaces the existing row of the same name; other supplied rows are added. */
UPSERT,

/** Existing rows with a supplied row's name are removed; only names are needed. */
REMOVE,
;

companion object {
fun of(text: String?): Mode =
text?.takeIf { it.isNotBlank() }?.let { value -> values().firstOrNull { it.name.equals(value, ignoreCase = true) } }
?: if (text.isNullOrBlank()) REPLACE else throw IllegalArgumentException("tableMode must be replace, append, upsert or remove")
}
}

private fun rowName(row: TestElement): String? =
runCatching { row.javaClass.getMethod("getName").invoke(row) as? String }.getOrNull()

fun configure(element: TestElement, tables: JsonNode, mode: Mode = Mode.REPLACE) {
require(tables.isObject) { "tables must be an object" }
val types = rowTypes(element)
for ((name, values) in tables.properties()) {
val type = types[name] ?: error("Unknown table '$name'; inspect the element schema first")
require(values.isArray) { "$name must be an array of row objects" }
val rows = values.map { AgentElementCatalog.configured(newRow(type), it) }
val supplied = values.map { AgentElementCatalog.configured(newRow(type), it) }
// Header names are case-insensitive; parameter and variable names are not.
val sameName: (String?, String?) -> Boolean =
if (name == "headers") { a, b -> a.equals(b, ignoreCase = true) } else { a, b -> a == b }
val existing = if (mode == Mode.REPLACE) emptyList() else rowElements(element, name)
val rows = when (mode) {
Mode.REPLACE -> supplied
Mode.APPEND -> existing + supplied
Mode.UPSERT -> {
val merged = existing.toMutableList()
for (row in supplied) {
val at = merged.indexOfFirst { sameName(rowName(it), rowName(row)) }
if (at >= 0) merged[at] = row else merged += row
}
merged
}
Mode.REMOVE -> existing.filter { old -> supplied.none { sameName(rowName(it), rowName(old)) } }
}
when {
name == "headers" && isType(element, HTTP_SAMPLER) ->
element.javaClass.getMethod("setNativeHeaders", List::class.java).invoke(element, rows)
isType(element, WS_CONNECT) -> element.javaClass.getMethod("setHeaders", List::class.java).invoke(element, rows)
isType(element, HEADER_MANAGER) -> {
val headers = element.javaClass.getMethod("getHeaders").invoke(element) as org.apache.jmeter.testelement.property.CollectionProperty
val headers = element.javaClass.getMethod("getHeaders").invoke(element) as CollectionProperty
headers.clear()
rows.forEach { element.javaClass.getMethod("add", Class.forName(HEADER)).invoke(element, it) }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ public class AgentPlanSummarizer(
return this
}
if (limit == 0) {
return "... [DSL omitted $length chars]"
return "... [DSL omitted $length chars; pass includeDsl=true, or use get_plan_outline for the structure]"
}
return take(limit) + "\n... [DSL truncated ${length - limit} chars]"
}
Expand Down
Loading
Loading