evoloop-cli 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. evoloop_cli/__init__.py +3 -0
  2. evoloop_cli/__main__.py +10 -0
  3. evoloop_cli/_skills/evoloop-constitution/SKILL.md +59 -0
  4. evoloop_cli/_skills/evoloop-constitution/references/writing-guide.md +89 -0
  5. evoloop_cli/_skills/evoloop-constitution/templates/config.yaml +52 -0
  6. evoloop_cli/_skills/evoloop-constitution/templates/constitution.md +39 -0
  7. evoloop_cli/_skills/evoloop-evaluate/SKILL.md +85 -0
  8. evoloop_cli/_skills/evoloop-evaluate/schemas/parsed_report.schema.json +170 -0
  9. evoloop_cli/_skills/evoloop-evaluate/scripts/parse_junit_report.py +311 -0
  10. evoloop_cli/_skills/evoloop-evaluate/scripts/parse_pytest_report.py +276 -0
  11. evoloop_cli/_skills/evoloop-evaluate/scripts/parse_report.py +101 -0
  12. evoloop_cli/_skills/evoloop-evaluate/scripts/update_eval_index.py +111 -0
  13. evoloop_cli/_skills/evoloop-evaluate/scripts/validate_parsed_report.py +178 -0
  14. evoloop_cli/_skills/evoloop-evaluate/templates/analysis.md +51 -0
  15. evoloop_cli/_skills/evoloop-evaluate/templates/progress.md +42 -0
  16. evoloop_cli/_skills/evoloop-evaluate/templates/tasks.md +34 -0
  17. evoloop_cli/_skills/evoloop-evolve/SKILL.md +76 -0
  18. evoloop_cli/_skills/evoloop-evolve/scripts/evolve_state.py +333 -0
  19. evoloop_cli/_skills/evoloop-implement/SKILL.md +57 -0
  20. evoloop_cli/_skills/evoloop-implement/scripts/check_scope.py +154 -0
  21. evoloop_cli/_skills/evoloop-implement/scripts/commit_section.py +78 -0
  22. evoloop_cli/_skills/evoloop-init/SKILL.md +95 -0
  23. evoloop_cli/_skills/evoloop-init/scripts/scaffold_evals.py +546 -0
  24. evoloop_cli/_skills/evoloop-init/templates/common/evals/datasets/domain_flows.yaml +33 -0
  25. evoloop_cli/_skills/evoloop-init/templates/common/evaluations/README.md +9 -0
  26. evoloop_cli/_skills/evoloop-init/templates/java/src/test/java/__PACKAGE_PATH__/evals/AgentAdapter.java +13 -0
  27. evoloop_cli/_skills/evoloop-init/templates/java/src/test/java/__PACKAGE_PATH__/evals/AgenticFlowEvalTest.java +71 -0
  28. evoloop_cli/_skills/evoloop-init/templates/java/src/test/java/__PACKAGE_PATH__/evals/DeterministicEvaluators.java +174 -0
  29. evoloop_cli/_skills/evoloop-init/templates/java/src/test/java/__PACKAGE_PATH__/evals/EvalFrameworkTest.java +45 -0
  30. evoloop_cli/_skills/evoloop-init/templates/java/src/test/java/__PACKAGE_PATH__/evals/FlowRunResult.java +25 -0
  31. evoloop_cli/_skills/evoloop-init/templates/python/evals/__init__.py +1 -0
  32. evoloop_cli/_skills/evoloop-init/templates/python/evals/adapter.py +63 -0
  33. evoloop_cli/_skills/evoloop-init/templates/python/evals/deepagents_adapter.py +223 -0
  34. evoloop_cli/_skills/evoloop-init/templates/python/evals/evaluators/__init__.py +1 -0
  35. evoloop_cli/_skills/evoloop-init/templates/python/evals/evaluators/deterministic.py +234 -0
  36. evoloop_cli/_skills/evoloop-init/templates/python/evals/evaluators/llm_judge.py +189 -0
  37. evoloop_cli/_skills/evoloop-init/templates/python/evals/fakes.py +26 -0
  38. evoloop_cli/_skills/evoloop-init/templates/python/evals/harness.py +100 -0
  39. evoloop_cli/_skills/evoloop-init/templates/python/tests/conftest.py +38 -0
  40. evoloop_cli/_skills/evoloop-init/templates/python/tests/test_agentic_flows.py +36 -0
  41. evoloop_cli/_skills/evoloop-init/templates/python/tests/test_eval_framework.py +175 -0
  42. evoloop_cli/_skills/evoloop-new/SKILL.md +125 -0
  43. evoloop_cli/_skills/evoloop-new/scripts/scaffold_agent.py +911 -0
  44. evoloop_cli/_skills/evoloop-new/templates/common/.evoloop/constitution.md +34 -0
  45. evoloop_cli/_skills/evoloop-new/templates/common/.gitignore +22 -0
  46. evoloop_cli/_skills/evoloop-new/templates/common/AGENTS.md +17 -0
  47. evoloop_cli/_skills/evoloop-new/templates/common/README.md +83 -0
  48. evoloop_cli/_skills/evoloop-new/templates/common/skills/__DOMAIN__/SKILL.md +21 -0
  49. evoloop_cli/_skills/evoloop-new/templates/java/eval_wiring/src/test/java/__PACKAGE_PATH__/evals/AgenticFlowEvalTest.java +113 -0
  50. evoloop_cli/_skills/evoloop-new/templates/java/eval_wiring/src/test/java/__PACKAGE_PATH__/evals/EvalFrameworkTest.java +85 -0
  51. evoloop_cli/_skills/evoloop-new/templates/java/eval_wiring/src/test/java/__PACKAGE_PATH__/evals/Fake__DOMAIN_PASCAL__Client.java +37 -0
  52. evoloop_cli/_skills/evoloop-new/templates/java/frameworks/custom/src/main/java/__PACKAGE_PATH__/Application.java +46 -0
  53. evoloop_cli/_skills/evoloop-new/templates/java/frameworks/custom/src/main/java/__PACKAGE_PATH__/OpenAiCompatibleRunner.java +433 -0
  54. evoloop_cli/_skills/evoloop-new/templates/java/frameworks/custom/src/main/java/__PACKAGE_PATH__/__DOMAIN_PASCAL__Agent.java +125 -0
  55. evoloop_cli/_skills/evoloop-new/templates/java/frameworks/langchain4j/src/main/java/__PACKAGE_PATH__/Application.java +46 -0
  56. evoloop_cli/_skills/evoloop-new/templates/java/frameworks/langchain4j/src/main/java/__PACKAGE_PATH__/__DOMAIN_PASCAL__Agent.java +163 -0
  57. evoloop_cli/_skills/evoloop-new/templates/java/frameworks/langchain4j/src/main/java/__PACKAGE_PATH__/__DOMAIN_PASCAL__Tools.java +18 -0
  58. evoloop_cli/_skills/evoloop-new/templates/java/frameworks/micronaut/src/main/java/__PACKAGE_PATH__/Application.java +15 -0
  59. evoloop_cli/_skills/evoloop-new/templates/java/frameworks/micronaut/src/main/java/__PACKAGE_PATH__/__DOMAIN_PASCAL__Agent.java +167 -0
  60. evoloop_cli/_skills/evoloop-new/templates/java/frameworks/micronaut/src/main/java/__PACKAGE_PATH__/__DOMAIN_PASCAL__Controller.java +41 -0
  61. evoloop_cli/_skills/evoloop-new/templates/java/frameworks/micronaut/src/main/java/__PACKAGE_PATH__/__DOMAIN_PASCAL__Factory.java +32 -0
  62. evoloop_cli/_skills/evoloop-new/templates/java/frameworks/micronaut/src/main/java/__PACKAGE_PATH__/__DOMAIN_PASCAL__Tools.java +20 -0
  63. evoloop_cli/_skills/evoloop-new/templates/java/frameworks/micronaut/src/main/resources/application.yml +17 -0
  64. evoloop_cli/_skills/evoloop-new/templates/java/frameworks/spring-ai/src/main/java/__PACKAGE_PATH__/Application.java +17 -0
  65. evoloop_cli/_skills/evoloop-new/templates/java/frameworks/spring-ai/src/main/java/__PACKAGE_PATH__/__DOMAIN_PASCAL__Agent.java +159 -0
  66. evoloop_cli/_skills/evoloop-new/templates/java/frameworks/spring-ai/src/main/java/__PACKAGE_PATH__/__DOMAIN_PASCAL__Config.java +32 -0
  67. evoloop_cli/_skills/evoloop-new/templates/java/frameworks/spring-ai/src/main/java/__PACKAGE_PATH__/__DOMAIN_PASCAL__Controller.java +40 -0
  68. evoloop_cli/_skills/evoloop-new/templates/java/frameworks/spring-ai/src/main/java/__PACKAGE_PATH__/__DOMAIN_PASCAL__Tools.java +25 -0
  69. evoloop_cli/_skills/evoloop-new/templates/java/frameworks/spring-ai/src/main/resources/application.yml +19 -0
  70. evoloop_cli/_skills/evoloop-new/templates/java/gradle/build_custom.gradle +33 -0
  71. evoloop_cli/_skills/evoloop-new/templates/java/gradle/build_langchain4j.gradle +40 -0
  72. evoloop_cli/_skills/evoloop-new/templates/java/gradle/build_micronaut.gradle +52 -0
  73. evoloop_cli/_skills/evoloop-new/templates/java/gradle/build_spring-ai.gradle +45 -0
  74. evoloop_cli/_skills/evoloop-new/templates/java/gradle/settings.gradle +1 -0
  75. evoloop_cli/_skills/evoloop-new/templates/java/maven/pom_custom.xml +57 -0
  76. evoloop_cli/_skills/evoloop-new/templates/java/maven/pom_langchain4j.xml +87 -0
  77. evoloop_cli/_skills/evoloop-new/templates/java/maven/pom_micronaut.xml +101 -0
  78. evoloop_cli/_skills/evoloop-new/templates/java/maven/pom_spring-ai.xml +61 -0
  79. evoloop_cli/_skills/evoloop-new/templates/java/src/main/java/__PACKAGE_PATH__/ConversationMemory.java +36 -0
  80. evoloop_cli/_skills/evoloop-new/templates/java/src/main/java/__PACKAGE_PATH__/Default__DOMAIN_PASCAL__Client.java +9 -0
  81. evoloop_cli/_skills/evoloop-new/templates/java/src/main/java/__PACKAGE_PATH__/DomainRecord.java +10 -0
  82. evoloop_cli/_skills/evoloop-new/templates/java/src/main/java/__PACKAGE_PATH__/TurnOutcome.java +15 -0
  83. evoloop_cli/_skills/evoloop-new/templates/java/src/main/java/__PACKAGE_PATH__/__DOMAIN_PASCAL__Client.java +8 -0
  84. evoloop_cli/_skills/evoloop-new/templates/python/eval_wiring/evals/fakes.py +22 -0
  85. evoloop_cli/_skills/evoloop-new/templates/python/eval_wiring/evals/harness_custom.py +186 -0
  86. evoloop_cli/_skills/evoloop-new/templates/python/eval_wiring/evals/harness_deepagents.py +100 -0
  87. evoloop_cli/_skills/evoloop-new/templates/python/eval_wiring/tests/test_eval_framework.py +196 -0
  88. evoloop_cli/_skills/evoloop-new/templates/python/pyproject.toml +18 -0
  89. evoloop_cli/_skills/evoloop-new/templates/python/src/__PACKAGE__/__init__.py +13 -0
  90. evoloop_cli/_skills/evoloop-new/templates/python/src/__PACKAGE__/__main__.py +6 -0
  91. evoloop_cli/_skills/evoloop-new/templates/python/src/__PACKAGE__/agent_custom.py +209 -0
  92. evoloop_cli/_skills/evoloop-new/templates/python/src/__PACKAGE__/agent_deepagents.py +61 -0
  93. evoloop_cli/_skills/evoloop-new/templates/python/src/__PACKAGE__/cli.py +71 -0
  94. evoloop_cli/_skills/evoloop-new/templates/python/src/__PACKAGE__/client.py +31 -0
  95. evoloop_cli/_skills/evoloop-scenarios/SKILL.md +49 -0
  96. evoloop_cli/_skills/evoloop-scenarios/scripts/validate_scenarios.py +261 -0
  97. evoloop_cli/_skills/evoloop-scenarios/templates/scenario_schema.md +49 -0
  98. evoloop_cli/cli.py +331 -0
  99. evoloop_cli-0.1.0.dist-info/METADATA +214 -0
  100. evoloop_cli-0.1.0.dist-info/RECORD +103 -0
  101. evoloop_cli-0.1.0.dist-info/WHEEL +4 -0
  102. evoloop_cli-0.1.0.dist-info/entry_points.txt +2 -0
  103. evoloop_cli-0.1.0.dist-info/licenses/LICENSE +202 -0
@@ -0,0 +1,13 @@
1
+ package __JAVA_PACKAGE__.evals;
2
+
3
+ import java.util.Map;
4
+ import java.util.Set;
5
+
6
+ /**
7
+ * Framework-agnostic Java adapter interface for running single- or multi-turn agent flows.
8
+ * Implement this for Spring AI, LangChain4j, ADK-Java, or any custom Java agent runtime.
9
+ */
10
+ @FunctionalInterface
11
+ public interface AgentAdapter {
12
+ FlowRunResult runCase(Map<String, Object> flowCase, Set<String> domainTools);
13
+ }
@@ -0,0 +1,71 @@
1
+ package __JAVA_PACKAGE__.evals;
2
+
3
+ import static org.junit.jupiter.api.Assertions.assertTrue;
4
+
5
+ import __JAVA_PACKAGE__.evals.FlowRunResult.EvalOutcome;
6
+ import java.io.InputStream;
7
+ import java.nio.file.Files;
8
+ import java.nio.file.Path;
9
+ import java.util.List;
10
+ import java.util.Map;
11
+ import java.util.Set;
12
+ import java.util.stream.Stream;
13
+ import org.junit.jupiter.api.Named;
14
+ import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
15
+ import org.junit.jupiter.params.ParameterizedTest;
16
+ import org.junit.jupiter.params.provider.Arguments;
17
+ import org.junit.jupiter.params.provider.MethodSource;
18
+ import org.yaml.snakeyaml.Yaml;
19
+
20
+ /**
21
+ * End-to-end JUnit 5 agentic flow evaluation suite for __DOMAIN_TITLE__.
22
+ *
23
+ * Run live evaluations:
24
+ * Maven: mvn test -Dtest=AgenticFlowEvalTest -DrunLiveAgent=true
25
+ * Gradle: ./gradlew test --tests '*AgenticFlowEvalTest' -DrunLiveAgent=true
26
+ */
27
+ @EnabledIfSystemProperty(named = "runLiveAgent", matches = "true")
28
+ class AgenticFlowEvalTest {
29
+
30
+ // TODO(domain): List all domain tool names exposed by your Java agent.
31
+ static final Set<String> DOMAIN_TOOLS = Set.of("example_tool");
32
+ static final Path DATASET_PATH = Path.of("evals/datasets/__DOMAIN___flows.yaml");
33
+
34
+ static AgentAdapter createAdapter() {
35
+ // TODO(domain): Wire this to your Spring AI / LangChain4j / ADK-Java agent with a fake client.
36
+ throw new UnsupportedOperationException(
37
+ "Wire AgenticFlowEvalTest.createAdapter() to your project's Java agent factory.");
38
+ }
39
+
40
+ @SuppressWarnings("unchecked")
41
+ static Stream<Arguments> flowCases() throws Exception {
42
+ Yaml yaml = new Yaml();
43
+ try (InputStream in = Files.newInputStream(DATASET_PATH)) {
44
+ Map<String, Object> root = yaml.load(in);
45
+ List<Map<String, Object>> cases = (List<Map<String, Object>>) root.get("cases");
46
+ return cases.stream()
47
+ .map(c -> Arguments.of(Named.of(String.valueOf(c.get("id")), c)));
48
+ }
49
+ }
50
+
51
+ @ParameterizedTest(name = "{0}")
52
+ @MethodSource("flowCases")
53
+ void testAgenticFlow(Map<String, Object> flowCase) {
54
+ FlowRunResult run = createAdapter().runCase(flowCase, DOMAIN_TOOLS);
55
+ List<EvalOutcome> outcomes = DeterministicEvaluators.runAll(run, flowCase);
56
+
57
+ // Standardized assertion format parsed by parse_junit_report.py into parsed.json (v1.0)
58
+ List<String> failures = outcomes.stream()
59
+ .filter(o -> !o.passed())
60
+ .map(o -> " - [" + o.name() + "] " + o.reason())
61
+ .toList();
62
+
63
+ assertTrue(
64
+ failures.isEmpty(),
65
+ () -> "Flow '" + flowCase.get("id") + "' failed " + failures.size() + " check(s):\n"
66
+ + String.join("\n", failures)
67
+ + "\nFinal response: " + run.finalResponse()
68
+ + "\nDomain tool calls: " + run.domainToolCalls()
69
+ + "\nSkill loaded (SKILL.md): " + run.skillLoaded());
70
+ }
71
+ }
@@ -0,0 +1,174 @@
1
+ package __JAVA_PACKAGE__.evals;
2
+
3
+ import __JAVA_PACKAGE__.evals.FlowRunResult.DomainToolCall;
4
+ import __JAVA_PACKAGE__.evals.FlowRunResult.EvalOutcome;
5
+ import java.util.ArrayList;
6
+ import java.util.HashSet;
7
+ import java.util.List;
8
+ import java.util.Locale;
9
+ import java.util.Map;
10
+ import java.util.Set;
11
+ import java.util.TreeMap;
12
+
13
+ /** Deterministic evaluators matching the Evoloop contract (trajectory_match, tool_policy, efficiency_budget, groundedness). */
14
+ public final class DeterministicEvaluators {
15
+
16
+ private DeterministicEvaluators() {}
17
+
18
+ @SuppressWarnings("unchecked")
19
+ public static EvalOutcome evaluateTrajectoryMatch(FlowRunResult run, Map<String, Object> flowCase) {
20
+ List<Map<String, Object>> expected =
21
+ (List<Map<String, Object>>) flowCase.getOrDefault("expected_tool_calls", List.of());
22
+ String mode = String.valueOf(flowCase.getOrDefault("trajectory_match_mode", "unordered"));
23
+
24
+ if (expected.isEmpty()) {
25
+ if ("strict".equals(mode)) {
26
+ boolean passed = run.domainToolCalls().isEmpty();
27
+ return new EvalOutcome(
28
+ "trajectory_match",
29
+ passed,
30
+ passed ? 1.0 : 0.0,
31
+ passed
32
+ ? "No domain tool calls made as expected."
33
+ : "Expected 0 domain tool calls, got: " + run.domainToolCalls());
34
+ }
35
+ return new EvalOutcome(
36
+ "trajectory_match", true, 1.0, "No mandatory reference tool calls required (mode=" + mode + ").");
37
+ }
38
+
39
+ List<String> actualKeys = run.domainToolCalls().stream()
40
+ .map(c -> canonicalKey(c.name(), c.args()))
41
+ .toList();
42
+ List<String> expectedKeys = expected.stream()
43
+ .map(tc -> canonicalKey(
44
+ String.valueOf(tc.get("name")),
45
+ (Map<String, Object>) tc.getOrDefault("args", Map.of())))
46
+ .toList();
47
+
48
+ boolean passed = switch (mode) {
49
+ case "strict" -> actualKeys.equals(expectedKeys);
50
+ case "unordered" -> actualKeys.size() == expectedKeys.size()
51
+ && new HashSet<>(actualKeys).equals(new HashSet<>(expectedKeys));
52
+ case "superset" -> new HashSet<>(actualKeys).containsAll(expectedKeys);
53
+ case "subset" -> new HashSet<>(expectedKeys).containsAll(actualKeys);
54
+ default -> false;
55
+ };
56
+
57
+ return new EvalOutcome(
58
+ "trajectory_match",
59
+ passed,
60
+ passed ? 1.0 : 0.0,
61
+ passed
62
+ ? "Trajectory matched (" + mode + ")."
63
+ : "Trajectory mismatch (" + mode + "). Expected " + expectedKeys + ", got " + actualKeys);
64
+ }
65
+
66
+ @SuppressWarnings("unchecked")
67
+ public static EvalOutcome evaluateToolPolicy(FlowRunResult run, Map<String, Object> flowCase) {
68
+ List<String> violations = new ArrayList<>();
69
+ Set<String> overallForbidden = new HashSet<>(
70
+ (List<String>) flowCase.getOrDefault("forbidden_tools", List.of()));
71
+ for (DomainToolCall call : run.domainToolCalls()) {
72
+ if (overallForbidden.contains(call.name())) {
73
+ violations.add("Forbidden tool called: " + call.name());
74
+ }
75
+ }
76
+
77
+ List<Map<String, Object>> turnAssertions =
78
+ (List<Map<String, Object>>) flowCase.getOrDefault("turn_assertions", List.of());
79
+ for (Map<String, Object> assertion : turnAssertions) {
80
+ int turnIdx = ((Number) assertion.get("turn_index")).intValue();
81
+ if (turnIdx >= run.turns().size()) {
82
+ violations.add("Turn " + turnIdx + " missing from run.");
83
+ continue;
84
+ }
85
+ List<String> turnTools = run.turns().get(turnIdx).domainToolCalls().stream()
86
+ .map(DomainToolCall::name)
87
+ .toList();
88
+ for (String f : (List<String>) assertion.getOrDefault("forbidden_tools", List.of())) {
89
+ if (turnTools.contains(f)) {
90
+ violations.add("Turn " + turnIdx + " called forbidden tool: " + f);
91
+ }
92
+ }
93
+ for (String req : (List<String>) assertion.getOrDefault("required_tools", List.of())) {
94
+ if (!turnTools.contains(req)) {
95
+ violations.add("Turn " + turnIdx + " missed required tool: " + req + " (called: " + turnTools + ")");
96
+ }
97
+ }
98
+ }
99
+
100
+ boolean passed = violations.isEmpty();
101
+ return new EvalOutcome(
102
+ "tool_policy",
103
+ passed,
104
+ passed ? 1.0 : 0.0,
105
+ passed ? "All tool policy constraints satisfied." : String.join("; ", violations));
106
+ }
107
+
108
+ public static EvalOutcome evaluateEfficiencyBudget(FlowRunResult run, Map<String, Object> flowCase) {
109
+ List<String> issues = new ArrayList<>();
110
+ Object maxObj = flowCase.get("max_tool_calls");
111
+ if (maxObj instanceof Number maxCalls && run.domainToolCalls().size() > maxCalls.intValue()) {
112
+ issues.add("Exceeded max_tool_calls (" + run.domainToolCalls().size() + " > " + maxCalls.intValue() + ").");
113
+ }
114
+ boolean allowDup = Boolean.TRUE.equals(flowCase.get("allow_duplicate_calls"));
115
+ if (!allowDup) {
116
+ Set<String> seen = new HashSet<>();
117
+ for (DomainToolCall call : run.domainToolCalls()) {
118
+ String key = call.turnIndex() + ":" + canonicalKey(call.name(), call.args());
119
+ if (!seen.add(key)) {
120
+ issues.add("Duplicate redundant tool call detected: turn " + call.turnIndex() + " " + call.name());
121
+ }
122
+ }
123
+ }
124
+ boolean passed = issues.isEmpty();
125
+ return new EvalOutcome(
126
+ "efficiency_budget",
127
+ passed,
128
+ passed ? 1.0 : 0.0,
129
+ passed ? "Within budget (" + run.domainToolCalls().size() + " tool calls)." : String.join("; ", issues));
130
+ }
131
+
132
+ @SuppressWarnings("unchecked")
133
+ public static EvalOutcome evaluateGroundedness(FlowRunResult run, Map<String, Object> flowCase) {
134
+ String responseLower = run.finalResponse() == null ? "" : run.finalResponse().toLowerCase(Locale.ROOT);
135
+ List<String> issues = new ArrayList<>();
136
+ if (responseLower.isBlank()) {
137
+ issues.add("Final agent response is empty.");
138
+ } else {
139
+ for (List<String> group : (List<List<String>>) flowCase.getOrDefault("grounded_any_of", List.of())) {
140
+ boolean matched = group.stream().anyMatch(tok -> responseLower.contains(tok.toLowerCase(Locale.ROOT)));
141
+ if (!matched) {
142
+ issues.add("Expected one of " + group + " in final response.");
143
+ }
144
+ }
145
+ for (String forbidden : (List<String>) flowCase.getOrDefault("forbidden_substrings", List.of())) {
146
+ if (responseLower.contains(forbidden.toLowerCase(Locale.ROOT))) {
147
+ issues.add("Found forbidden substring '" + forbidden + "' in final response.");
148
+ }
149
+ }
150
+ }
151
+ boolean passed = issues.isEmpty();
152
+ return new EvalOutcome(
153
+ "groundedness",
154
+ passed,
155
+ passed ? 1.0 : 0.0,
156
+ passed ? "Final response is grounded in expected tool outputs." : String.join("; ", issues));
157
+ }
158
+
159
+ public static List<EvalOutcome> runAll(FlowRunResult run, Map<String, Object> flowCase) {
160
+ return List.of(
161
+ evaluateTrajectoryMatch(run, flowCase),
162
+ evaluateToolPolicy(run, flowCase),
163
+ evaluateEfficiencyBudget(run, flowCase),
164
+ evaluateGroundedness(run, flowCase));
165
+ }
166
+
167
+ private static String canonicalKey(String toolName, Map<String, Object> args) {
168
+ TreeMap<String, String> sorted = new TreeMap<>();
169
+ if (args != null) {
170
+ args.forEach((k, v) -> sorted.put(k, String.valueOf(v).trim().toLowerCase(Locale.ROOT)));
171
+ }
172
+ return toolName + sorted;
173
+ }
174
+ }
@@ -0,0 +1,45 @@
1
+ package __JAVA_PACKAGE__.evals;
2
+
3
+ import static org.junit.jupiter.api.Assertions.assertFalse;
4
+ import static org.junit.jupiter.api.Assertions.assertTrue;
5
+
6
+ import __JAVA_PACKAGE__.evals.FlowRunResult.DomainToolCall;
7
+ import __JAVA_PACKAGE__.evals.FlowRunResult.EvalOutcome;
8
+ import __JAVA_PACKAGE__.evals.FlowRunResult.TurnResult;
9
+ import java.util.List;
10
+ import java.util.Map;
11
+ import org.junit.jupiter.api.Test;
12
+
13
+ /** Fast offline JUnit 5 unit tests for the Java evaluation framework (no LLM required). */
14
+ class EvalFrameworkTest {
15
+
16
+ @Test
17
+ void happyPathDeterministicEvaluatorsPass() {
18
+ Map<String, Object> flowCase = Map.of(
19
+ "id", "happy_path_example",
20
+ "expected_tool_calls", List.of(Map.of("name", "example_tool", "args", Map.of("query", "item-1"))),
21
+ "trajectory_match_mode", "unordered",
22
+ "max_tool_calls", 2,
23
+ "grounded_any_of", List.of(List.of("item-1")));
24
+
25
+ DomainToolCall call = new DomainToolCall("example_tool", Map.of("query", "item-1"), 0);
26
+ FlowRunResult run = new FlowRunResult(
27
+ "happy_path_example",
28
+ List.of(new TurnResult(0, "Lookup item-1", List.of(call), "Status for item-1 is ok.", 0.1)),
29
+ List.of(call),
30
+ "Status for item-1 is ok.",
31
+ 0.1,
32
+ false);
33
+
34
+ List<EvalOutcome> outcomes = DeterministicEvaluators.runAll(run, flowCase);
35
+ assertTrue(outcomes.stream().allMatch(EvalOutcome::passed), "Expected all checks to pass: " + outcomes);
36
+ }
37
+
38
+ @Test
39
+ void emptyResponseFailsGroundedness() {
40
+ FlowRunResult emptyRun = new FlowRunResult("empty", List.of(), List.of(), " ", 0.1, false);
41
+ EvalOutcome outcome = DeterministicEvaluators.evaluateGroundedness(
42
+ emptyRun, Map.of("grounded_any_of", List.of(List.of("ok"))));
43
+ assertFalse(outcome.passed());
44
+ }
45
+ }
@@ -0,0 +1,25 @@
1
+ package __JAVA_PACKAGE__.evals;
2
+
3
+ import java.util.List;
4
+ import java.util.Map;
5
+
6
+ /** Framework-agnostic evaluation trace records for __DOMAIN_TITLE__ agentic flows. */
7
+ public record FlowRunResult(
8
+ String caseId,
9
+ List<TurnResult> turns,
10
+ List<DomainToolCall> domainToolCalls,
11
+ String finalResponse,
12
+ double totalLatencySeconds,
13
+ boolean skillLoaded) {
14
+
15
+ public record DomainToolCall(String name, Map<String, Object> args, int turnIndex) {}
16
+
17
+ public record TurnResult(
18
+ int turnIndex,
19
+ String userInput,
20
+ List<DomainToolCall> domainToolCalls,
21
+ String finalResponse,
22
+ double latencySeconds) {}
23
+
24
+ public record EvalOutcome(String name, boolean passed, double score, String reason) {}
25
+ }
@@ -0,0 +1 @@
1
+ """Evaluation package for __DOMAIN_TITLE__ agentic flows."""
@@ -0,0 +1,63 @@
1
+ """Framework-agnostic evaluation data structures and AgentAdapter protocol."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from dataclasses import dataclass, field
6
+ from typing import Any, Protocol, runtime_checkable
7
+
8
+
9
+ @dataclass(frozen=True)
10
+ class DomainToolCall:
11
+ """A single domain-level tool invocation captured from an agent trajectory."""
12
+
13
+ name: str
14
+ args: dict[str, Any]
15
+ turn_index: int
16
+ call_id: str | None = None
17
+
18
+
19
+ @dataclass
20
+ class TurnResult:
21
+ """Captured state for a single user turn in a flow."""
22
+
23
+ turn_index: int
24
+ user_input: str
25
+ new_messages: list[Any]
26
+ domain_tool_calls: list[DomainToolCall]
27
+ final_response: str
28
+ latency_seconds: float
29
+ openai_turn_messages: list[dict[str, Any]] = field(default_factory=list)
30
+
31
+
32
+ @dataclass
33
+ class FlowRunResult:
34
+ """Complete execution trace and metrics for an agentic flow run."""
35
+
36
+ case_id: str
37
+ turns: list[TurnResult]
38
+ all_messages: list[Any]
39
+ domain_tool_calls: list[DomainToolCall]
40
+ openai_trajectory: list[dict[str, Any]]
41
+ final_response: str
42
+ total_latency_seconds: float
43
+ fake_client_log: list[dict[str, Any]] = field(default_factory=list)
44
+ skill_loaded: bool = False
45
+
46
+
47
+ @runtime_checkable
48
+ class AgentAdapter(Protocol):
49
+ """Framework adapter interface for running single- or multi-turn agent flows."""
50
+
51
+ async def run_case(
52
+ self,
53
+ case: dict[str, Any],
54
+ *,
55
+ fake_client: Any,
56
+ domain_tools: frozenset[str],
57
+ base_url: str | None = None,
58
+ model: str | None = None,
59
+ api_key: str | None = None,
60
+ thread_id: str | None = None,
61
+ ) -> FlowRunResult:
62
+ """Execute all user turns in `case` and return a standardized FlowRunResult."""
63
+ ...
@@ -0,0 +1,223 @@
1
+ """Built-in AgentAdapter for deepagents / LangChain message-based agents."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import json
6
+ import time
7
+ import uuid
8
+ from collections.abc import Callable
9
+ from typing import Any
10
+
11
+ from langchain_core.messages import AIMessage, HumanMessage, ToolMessage
12
+
13
+ from .adapter import DomainToolCall, FlowRunResult, TurnResult
14
+
15
+
16
+ def extract_text_content(content: Any) -> str:
17
+ """Extract plain text from a LangChain message content field."""
18
+ if isinstance(content, str):
19
+ return content.strip()
20
+ if isinstance(content, list):
21
+ parts = [
22
+ part.get("text", "")
23
+ for part in content
24
+ if isinstance(part, dict) and part.get("type") == "text"
25
+ ]
26
+ return "\n".join(p for p in parts if p).strip()
27
+ return str(content).strip()
28
+
29
+
30
+ def detect_skill_loaded(
31
+ messages: list[Any],
32
+ skill_fragment: str = "SKILL.md",
33
+ ) -> bool:
34
+ """Return True if any middleware tool call in messages read the target skill file."""
35
+ target = skill_fragment.lower()
36
+ for msg in messages:
37
+ if isinstance(msg, AIMessage) and getattr(msg, "tool_calls", None):
38
+ for tc in msg.tool_calls:
39
+ args = tc.get("args") or {}
40
+ if any(target in str(v).lower() for v in args.values()):
41
+ return True
42
+ return False
43
+
44
+
45
+ def extract_domain_tool_calls(
46
+ messages: list[Any],
47
+ *,
48
+ domain_tools: frozenset[str],
49
+ turn_index: int = 0,
50
+ ) -> list[DomainToolCall]:
51
+ """Extract only domain tool calls from LangChain messages, ignoring middleware tools."""
52
+ calls: list[DomainToolCall] = []
53
+ for msg in messages:
54
+ if isinstance(msg, AIMessage) and getattr(msg, "tool_calls", None):
55
+ for tc in msg.tool_calls:
56
+ name = tc.get("name", "")
57
+ if name in domain_tools:
58
+ calls.append(
59
+ DomainToolCall(
60
+ name=name,
61
+ args=dict(tc.get("args") or {}),
62
+ turn_index=turn_index,
63
+ call_id=tc.get("id"),
64
+ )
65
+ )
66
+ return calls
67
+
68
+
69
+ def to_openai_domain_trajectory(
70
+ messages: list[Any],
71
+ *,
72
+ domain_tools: frozenset[str],
73
+ ) -> list[dict[str, Any]]:
74
+ """Convert LangChain messages into OpenAI-style trajectory dicts for agentevals.
75
+
76
+ Internal middleware tool calls (e.g., reading SKILL.md or AGENTS.md) and their
77
+ corresponding ToolMessages are filtered out so trajectory matching focuses on
78
+ domain agent behavior.
79
+ """
80
+ trajectory: list[dict[str, Any]] = []
81
+ domain_call_ids: set[str] = set()
82
+
83
+ for msg in messages:
84
+ if isinstance(msg, HumanMessage):
85
+ trajectory.append(
86
+ {"role": "user", "content": extract_text_content(msg.content)}
87
+ )
88
+ elif isinstance(msg, AIMessage):
89
+ raw_calls = getattr(msg, "tool_calls", None) or []
90
+ filtered_calls = []
91
+ for tc in raw_calls:
92
+ name = tc.get("name", "")
93
+ if name in domain_tools:
94
+ call_id = tc.get("id")
95
+ if call_id:
96
+ domain_call_ids.add(call_id)
97
+ filtered_calls.append(
98
+ {
99
+ "function": {
100
+ "name": name,
101
+ "arguments": json.dumps(tc.get("args") or {}, sort_keys=True),
102
+ }
103
+ }
104
+ )
105
+
106
+ text = extract_text_content(msg.content)
107
+ if filtered_calls:
108
+ trajectory.append(
109
+ {
110
+ "role": "assistant",
111
+ "content": text,
112
+ "tool_calls": filtered_calls,
113
+ }
114
+ )
115
+ elif text:
116
+ trajectory.append({"role": "assistant", "content": text})
117
+ elif isinstance(msg, ToolMessage):
118
+ name = getattr(msg, "name", "")
119
+ call_id = getattr(msg, "tool_call_id", None)
120
+ if name in domain_tools or (call_id and call_id in domain_call_ids):
121
+ trajectory.append(
122
+ {
123
+ "role": "tool",
124
+ "content": extract_text_content(msg.content),
125
+ }
126
+ )
127
+
128
+ return trajectory
129
+
130
+
131
+ class DeepAgentsAdapter:
132
+ """Adapter for deepagents / LangGraph compiled agents supporting `ainvoke`."""
133
+
134
+ def __init__(
135
+ self,
136
+ agent_factory: Callable[..., Any],
137
+ *,
138
+ skill_fragment: str = "SKILL.md",
139
+ ) -> None:
140
+ self._agent_factory = agent_factory
141
+ self._skill_fragment = skill_fragment
142
+
143
+ async def run_case(
144
+ self,
145
+ case: dict[str, Any],
146
+ *,
147
+ fake_client: Any,
148
+ domain_tools: frozenset[str],
149
+ base_url: str | None = None,
150
+ model: str | None = None,
151
+ api_key: str | None = None,
152
+ thread_id: str | None = None,
153
+ ) -> FlowRunResult:
154
+ agent = self._agent_factory(
155
+ client=fake_client,
156
+ base_url=base_url,
157
+ model=model,
158
+ api_key=api_key,
159
+ )
160
+ resolved_thread_id = thread_id or f"eval-{case['id']}-{uuid.uuid4().hex[:8]}"
161
+ config = {"configurable": {"thread_id": resolved_thread_id}}
162
+
163
+ turns: list[TurnResult] = []
164
+ all_messages: list[Any] = []
165
+ all_domain_calls: list[DomainToolCall] = []
166
+ total_latency = 0.0
167
+
168
+ for idx, user_prompt in enumerate(case["turns"]):
169
+ prev_count = len(all_messages)
170
+ start = time.perf_counter()
171
+ result = await agent.ainvoke(
172
+ {"messages": [("user", user_prompt)]},
173
+ config=config,
174
+ )
175
+ latency = time.perf_counter() - start
176
+ total_latency += latency
177
+
178
+ messages = list(result.get("messages", []))
179
+ new_messages = messages[prev_count:]
180
+ all_messages = messages
181
+
182
+ turn_calls = extract_domain_tool_calls(
183
+ new_messages, domain_tools=domain_tools, turn_index=idx
184
+ )
185
+ all_domain_calls.extend(turn_calls)
186
+
187
+ turn_final = ""
188
+ for msg in reversed(new_messages):
189
+ if isinstance(msg, AIMessage):
190
+ text = extract_text_content(msg.content)
191
+ if text:
192
+ turn_final = text
193
+ break
194
+
195
+ turns.append(
196
+ TurnResult(
197
+ turn_index=idx,
198
+ user_input=user_prompt,
199
+ new_messages=new_messages,
200
+ domain_tool_calls=turn_calls,
201
+ final_response=turn_final,
202
+ latency_seconds=latency,
203
+ openai_turn_messages=to_openai_domain_trajectory(
204
+ new_messages, domain_tools=domain_tools
205
+ ),
206
+ )
207
+ )
208
+
209
+ final_response = turns[-1].final_response if turns else ""
210
+ openai_traj = to_openai_domain_trajectory(all_messages, domain_tools=domain_tools)
211
+ call_log = list(getattr(fake_client, "call_log", []))
212
+
213
+ return FlowRunResult(
214
+ case_id=case["id"],
215
+ turns=turns,
216
+ all_messages=all_messages,
217
+ domain_tool_calls=all_domain_calls,
218
+ openai_trajectory=openai_traj,
219
+ final_response=final_response,
220
+ total_latency_seconds=total_latency,
221
+ fake_client_log=call_log,
222
+ skill_loaded=detect_skill_loaded(all_messages, self._skill_fragment),
223
+ )
@@ -0,0 +1 @@
1
+ """Deterministic and LLM-as-a-Judge evaluators."""