@opensearch-project/agent-health 0.6.0 → 0.7.0

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 (174) hide show
  1. package/cli/dist/index.js +722 -330
  2. package/dist/assets/index-D-Np_l_T.js +246 -0
  3. package/dist/assets/index-vZt9QZKf.css +1 -0
  4. package/dist/index.html +2 -2
  5. package/docs/CLI.md +138 -1
  6. package/docs/CONNECTORS.md +1 -1
  7. package/docs/SDK.md +126 -2
  8. package/docs/skills/add-connector/SKILL.md +5 -1
  9. package/lib/dist/lib/agentTrends.d.ts +210 -0
  10. package/lib/dist/lib/agentTrends.d.ts.map +1 -0
  11. package/lib/dist/lib/agentTrends.js +360 -0
  12. package/lib/dist/lib/agentTrends.js.map +1 -0
  13. package/lib/dist/lib/benchmarkCaseReview.d.ts +114 -0
  14. package/lib/dist/lib/benchmarkCaseReview.d.ts.map +1 -0
  15. package/lib/dist/lib/benchmarkCaseReview.js +177 -0
  16. package/lib/dist/lib/benchmarkCaseReview.js.map +1 -0
  17. package/lib/dist/lib/benchmarkRunsTable.d.ts +109 -0
  18. package/lib/dist/lib/benchmarkRunsTable.d.ts.map +1 -0
  19. package/lib/dist/lib/benchmarkRunsTable.js +212 -0
  20. package/lib/dist/lib/benchmarkRunsTable.js.map +1 -0
  21. package/lib/dist/lib/comparisonInsights.d.ts +49 -2
  22. package/lib/dist/lib/comparisonInsights.d.ts.map +1 -1
  23. package/lib/dist/lib/comparisonInsights.js +65 -7
  24. package/lib/dist/lib/comparisonInsights.js.map +1 -1
  25. package/lib/dist/lib/config/loader.d.ts.map +1 -1
  26. package/lib/dist/lib/config/loader.js +11 -1
  27. package/lib/dist/lib/config/loader.js.map +1 -1
  28. package/lib/dist/lib/dashboardMetrics.d.ts +11 -2
  29. package/lib/dist/lib/dashboardMetrics.d.ts.map +1 -1
  30. package/lib/dist/lib/dashboardMetrics.js +38 -3
  31. package/lib/dist/lib/dashboardMetrics.js.map +1 -1
  32. package/lib/dist/lib/evaluationRerun.d.ts +39 -0
  33. package/lib/dist/lib/evaluationRerun.d.ts.map +1 -1
  34. package/lib/dist/lib/evaluationRerun.js +49 -0
  35. package/lib/dist/lib/evaluationRerun.js.map +1 -1
  36. package/lib/dist/lib/judgeFailureSummary.d.ts +66 -0
  37. package/lib/dist/lib/judgeFailureSummary.d.ts.map +1 -0
  38. package/lib/dist/lib/judgeFailureSummary.js +68 -0
  39. package/lib/dist/lib/judgeFailureSummary.js.map +1 -0
  40. package/lib/dist/lib/judgeStrategies.d.ts +108 -0
  41. package/lib/dist/lib/judgeStrategies.d.ts.map +1 -0
  42. package/lib/dist/lib/judgeStrategies.js +135 -0
  43. package/lib/dist/lib/judgeStrategies.js.map +1 -0
  44. package/lib/dist/lib/matchers/expect.d.ts +21 -1
  45. package/lib/dist/lib/matchers/expect.d.ts.map +1 -1
  46. package/lib/dist/lib/matchers/expect.js +51 -0
  47. package/lib/dist/lib/matchers/expect.js.map +1 -1
  48. package/lib/dist/lib/matchers/judgeAccessor.d.ts +4 -0
  49. package/lib/dist/lib/matchers/judgeAccessor.d.ts.map +1 -1
  50. package/lib/dist/lib/matchers/judgeAccessor.js +13 -2
  51. package/lib/dist/lib/matchers/judgeAccessor.js.map +1 -1
  52. package/lib/dist/lib/matchers/judgeReasoningParse.d.ts +49 -0
  53. package/lib/dist/lib/matchers/judgeReasoningParse.d.ts.map +1 -0
  54. package/lib/dist/lib/matchers/judgeReasoningParse.js +128 -0
  55. package/lib/dist/lib/matchers/judgeReasoningParse.js.map +1 -0
  56. package/lib/dist/lib/matchers/types.d.ts +25 -0
  57. package/lib/dist/lib/matchers/types.d.ts.map +1 -1
  58. package/lib/dist/lib/resolveCanonicalRun.d.ts +23 -0
  59. package/lib/dist/lib/resolveCanonicalRun.d.ts.map +1 -0
  60. package/lib/dist/lib/resolveCanonicalRun.js +26 -0
  61. package/lib/dist/lib/resolveCanonicalRun.js.map +1 -0
  62. package/lib/dist/lib/runActions.d.ts +120 -0
  63. package/lib/dist/lib/runActions.d.ts.map +1 -0
  64. package/lib/dist/lib/runActions.js +130 -0
  65. package/lib/dist/lib/runActions.js.map +1 -0
  66. package/lib/dist/lib/runInsights.d.ts +86 -0
  67. package/lib/dist/lib/runInsights.d.ts.map +1 -0
  68. package/lib/dist/lib/runInsights.js +185 -0
  69. package/lib/dist/lib/runInsights.js.map +1 -0
  70. package/lib/dist/lib/runName.d.ts +29 -0
  71. package/lib/dist/lib/runName.d.ts.map +1 -0
  72. package/lib/dist/lib/runName.js +38 -0
  73. package/lib/dist/lib/runName.js.map +1 -0
  74. package/lib/dist/lib/runReportPath.d.ts +16 -0
  75. package/lib/dist/lib/runReportPath.d.ts.map +1 -0
  76. package/lib/dist/lib/runReportPath.js +22 -0
  77. package/lib/dist/lib/runReportPath.js.map +1 -0
  78. package/lib/dist/lib/runSort.d.ts +27 -0
  79. package/lib/dist/lib/runSort.d.ts.map +1 -0
  80. package/lib/dist/lib/runSort.js +31 -0
  81. package/lib/dist/lib/runSort.js.map +1 -0
  82. package/lib/dist/lib/runStats.d.ts +86 -6
  83. package/lib/dist/lib/runStats.d.ts.map +1 -1
  84. package/lib/dist/lib/runStats.js +170 -19
  85. package/lib/dist/lib/runStats.js.map +1 -1
  86. package/lib/dist/lib/testCases/define.d.ts.map +1 -1
  87. package/lib/dist/lib/testCases/define.js +93 -46
  88. package/lib/dist/lib/testCases/define.js.map +1 -1
  89. package/lib/dist/lib/testCases/judge.d.ts.map +1 -1
  90. package/lib/dist/lib/testCases/judge.js +22 -4
  91. package/lib/dist/lib/testCases/judge.js.map +1 -1
  92. package/lib/dist/lib/testCases/loader.d.ts +24 -0
  93. package/lib/dist/lib/testCases/loader.d.ts.map +1 -1
  94. package/lib/dist/lib/testCases/loader.js +253 -36
  95. package/lib/dist/lib/testCases/loader.js.map +1 -1
  96. package/lib/dist/lib/trajectoryStepDisplay.d.ts +25 -0
  97. package/lib/dist/lib/trajectoryStepDisplay.d.ts.map +1 -0
  98. package/lib/dist/lib/trajectoryStepDisplay.js +42 -0
  99. package/lib/dist/lib/trajectoryStepDisplay.js.map +1 -0
  100. package/lib/dist/lib/utils.d.ts +19 -0
  101. package/lib/dist/lib/utils.d.ts.map +1 -1
  102. package/lib/dist/lib/utils.js +27 -0
  103. package/lib/dist/lib/utils.js.map +1 -1
  104. package/lib/dist/services/connectors/claude-code/ClaudeCodeConnector.d.ts +68 -32
  105. package/lib/dist/services/connectors/claude-code/ClaudeCodeConnector.d.ts.map +1 -1
  106. package/lib/dist/services/connectors/claude-code/ClaudeCodeConnector.js +148 -125
  107. package/lib/dist/services/connectors/claude-code/ClaudeCodeConnector.js.map +1 -1
  108. package/lib/dist/services/connectors/kiro/KiroConnector.d.ts +21 -13
  109. package/lib/dist/services/connectors/kiro/KiroConnector.d.ts.map +1 -1
  110. package/lib/dist/services/connectors/kiro/KiroConnector.js +22 -25
  111. package/lib/dist/services/connectors/kiro/KiroConnector.js.map +1 -1
  112. package/lib/dist/services/connectors/pi/PiConnector.d.ts +49 -10
  113. package/lib/dist/services/connectors/pi/PiConnector.d.ts.map +1 -1
  114. package/lib/dist/services/connectors/pi/PiConnector.js +102 -86
  115. package/lib/dist/services/connectors/pi/PiConnector.js.map +1 -1
  116. package/lib/dist/services/connectors/subprocess/SubprocessConnector.d.ts +59 -14
  117. package/lib/dist/services/connectors/subprocess/SubprocessConnector.d.ts.map +1 -1
  118. package/lib/dist/services/connectors/subprocess/SubprocessConnector.js +87 -61
  119. package/lib/dist/services/connectors/subprocess/SubprocessConnector.js.map +1 -1
  120. package/lib/dist/services/evaluation/bedrockJudge.d.ts +11 -0
  121. package/lib/dist/services/evaluation/bedrockJudge.d.ts.map +1 -1
  122. package/lib/dist/services/evaluation/bedrockJudge.js +2 -0
  123. package/lib/dist/services/evaluation/bedrockJudge.js.map +1 -1
  124. package/lib/dist/services/evaluation/index.d.ts +18 -1
  125. package/lib/dist/services/evaluation/index.d.ts.map +1 -1
  126. package/lib/dist/services/evaluation/index.js +156 -19
  127. package/lib/dist/services/evaluation/index.js.map +1 -1
  128. package/lib/dist/services/metrics.d.ts +55 -0
  129. package/lib/dist/services/metrics.d.ts.map +1 -0
  130. package/lib/dist/services/metrics.js +89 -0
  131. package/lib/dist/services/metrics.js.map +1 -0
  132. package/lib/dist/services/storage/asyncBenchmarkStorage.d.ts.map +1 -1
  133. package/lib/dist/services/storage/asyncBenchmarkStorage.js +16 -0
  134. package/lib/dist/services/storage/asyncBenchmarkStorage.js.map +1 -1
  135. package/lib/dist/services/storage/asyncRunStorage.d.ts +11 -0
  136. package/lib/dist/services/storage/asyncRunStorage.d.ts.map +1 -1
  137. package/lib/dist/services/storage/asyncRunStorage.js +49 -2
  138. package/lib/dist/services/storage/asyncRunStorage.js.map +1 -1
  139. package/lib/dist/services/storage/asyncTestCaseStorage.d.ts +1 -1
  140. package/lib/dist/services/storage/asyncTestCaseStorage.d.ts.map +1 -1
  141. package/lib/dist/services/storage/asyncTestCaseStorage.js +2 -1
  142. package/lib/dist/services/storage/asyncTestCaseStorage.js.map +1 -1
  143. package/lib/dist/services/storage/opensearchClient.d.ts +12 -0
  144. package/lib/dist/services/storage/opensearchClient.d.ts.map +1 -1
  145. package/lib/dist/services/storage/opensearchClient.js.map +1 -1
  146. package/lib/dist/services/traces/browserRecovery.d.ts.map +1 -1
  147. package/lib/dist/services/traces/browserRecovery.js +3 -0
  148. package/lib/dist/services/traces/browserRecovery.js.map +1 -1
  149. package/lib/dist/services/traces/index.d.ts +8 -1
  150. package/lib/dist/services/traces/index.d.ts.map +1 -1
  151. package/lib/dist/services/traces/index.js +33 -12
  152. package/lib/dist/services/traces/index.js.map +1 -1
  153. package/lib/dist/services/traces/judgeAgentsHints.d.ts +98 -3
  154. package/lib/dist/services/traces/judgeAgentsHints.d.ts.map +1 -1
  155. package/lib/dist/services/traces/judgeAgentsHints.js +144 -3
  156. package/lib/dist/services/traces/judgeAgentsHints.js.map +1 -1
  157. package/lib/dist/services/traces/spansToTrajectory.js +4 -4
  158. package/lib/dist/services/traces/spansToTrajectory.js.map +1 -1
  159. package/lib/dist/services/traces/tracePoller.d.ts.map +1 -1
  160. package/lib/dist/services/traces/tracePoller.js +17 -20
  161. package/lib/dist/services/traces/tracePoller.js.map +1 -1
  162. package/lib/dist/services/traces/trajectoryMerge.d.ts +79 -0
  163. package/lib/dist/services/traces/trajectoryMerge.d.ts.map +1 -0
  164. package/lib/dist/services/traces/trajectoryMerge.js +109 -0
  165. package/lib/dist/services/traces/trajectoryMerge.js.map +1 -0
  166. package/lib/dist/types/index.d.ts +195 -2
  167. package/lib/dist/types/index.d.ts.map +1 -1
  168. package/lib/dist/types/index.js +24 -0
  169. package/lib/dist/types/index.js.map +1 -1
  170. package/package.json +6 -5
  171. package/server/dist/app.js +3398 -926
  172. package/server/dist/index.js +3401 -929
  173. package/dist/assets/index-BfxtxmKc.css +0 -1
  174. package/dist/assets/index-CrjAfDHu.js +0 -243
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAmB,MAAM,MAAM,CAAA;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAExC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAEhD,MAAM,UAAU,EAAE,CAAC,GAAG,MAAoB;IACxC,OAAO,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAA;AAC9B,CAAC;AAED,0DAA0D;AAE1D,4CAA4C;AAC5C,kDAAkD;AAClD,kDAAkD;AAClD,MAAM,uBAAuB,GAA2B;IACtD,iBAAiB,EAAE,8GAA8G;IACjI,mBAAmB,EAAE,gHAAgH;IACrI,iBAAiB,EAAE,iGAAiG;CACrH,CAAC;AAEF,sEAAsE;AACtE,+CAA+C;AAC/C,MAAM,mBAAmB,GAAG;IAC1B,uGAAuG;IACvG,mHAAmH;IACnH,uGAAuG;IACvG,uGAAu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;;;;GAKG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,IAAwE,EAAU,EAAE;IACrH,MAAM,MAAM,GAAG;QACb,OAAO,EAAE,kCAAkC;QAC3C,OAAO,EAAE,oCAAoC;QAC7C,KAAK,EAAE,gCAAgC;QACvC,OAAO,EAAE,oCAAoC;QAC7C,IAAI,EAAE,sCAAsC;QAC5C,SAAS,EAAE,kCAAkC;KAC9C,CAAC;IACF,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC;AACtB,CAAC,CAAC;AAEF,2DAA2D;AAE3D;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAE,MAAc,EAAU,EAAE;IAC/D,IAAI,IAAI,CAAC,MAAM,IAAI,MAAM;QAAE,OAAO,IAAI,CAAC;IACvC,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,IAAI,EAAE,GAAG,KAAK,CAAC;AAClD,CAAC,CAAC;AAEF,2EAA2E;AAE3E;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,oBAAoB,CAAC,QAAgB;IACnD,MAAM,KAAK,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;IACrC,IAAI,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QAC9E,OAAO,YAAY,CAAC;IACtB,CAAC;IACD,OAAO,YAAY,CAAC;AACtB,CAAC"}
@@ -3,8 +3,45 @@
3
3
  * Specialized subprocess connector for Claude Code CLI
4
4
  */
5
5
  import type { TrajectoryStep } from '../../../types/index.js';
6
- import { SubprocessConnector } from '../../../services/connectors/subprocess/SubprocessConnector.js';
6
+ import { SubprocessConnector, type SubprocessExecutionState } from '../../../services/connectors/subprocess/SubprocessConnector.js';
7
7
  import type { ConnectorAuth, ConnectorRequest, ConnectorProgressCallback, SubprocessConfig } from '../../../services/connectors/types.js';
8
+ /**
9
+ * Upper bound on the tool output text persisted per `tool_result` step
10
+ * (`content` + `toolOutput`). Larger outputs are cut here with an explicit
11
+ * truncation marker carrying the original length, so the judge knows it saw
12
+ * a prefix. The full stream stays in `report.rawEvents`. Sized to cover the
13
+ * largest single results observed live (~28 KB) without doubling every
14
+ * report; the judge's own per-step cap (`AH_JUDGE_TOOL_OUTPUT_CAP`, default
15
+ * 100 KB) is the outer bound.
16
+ */
17
+ export declare const CLAUDE_CODE_MAX_TOOL_OUTPUT_CHARS: number;
18
+ /**
19
+ * Per-invocation parse state for one Claude Code subprocess. See
20
+ * {@link SubprocessExecutionState} for why none of this may live on the
21
+ * (singleton) connector instance.
22
+ */
23
+ interface ClaudeCodeExecutionState extends SubprocessExecutionState {
24
+ /** Partial trailing NDJSON line carried between stdout chunks. */
25
+ outputBuffer: string;
26
+ thinkingBuffer: string;
27
+ textBuffer: string;
28
+ /**
29
+ * Claude Code's `session_id` (present on every stream-json event). Captured
30
+ * for Strategy D trace correlation — it equals the `session.id` attribute
31
+ * Claude Code stamps on its OTel spans. Surfaced to the report via
32
+ * {@link extraResultMetadata} → `report.sessionId`.
33
+ */
34
+ sessionId?: string;
35
+ /**
36
+ * `tool_use` blocks seen so far, keyed by their id, so the matching
37
+ * `tool_result` block (which only carries `tool_use_id`) can be attributed
38
+ * to a tool name. Entries are consumed on pairing.
39
+ */
40
+ pendingToolUses: Map<string, {
41
+ name: string;
42
+ input: unknown;
43
+ }>;
44
+ }
8
45
  /**
9
46
  * MCP server definition for Claude Code --mcp-config flag
10
47
  */
@@ -34,49 +71,31 @@ export interface ClaudeCodeConnectorConfig {
34
71
  timeout?: number;
35
72
  additionalArgs?: string[];
36
73
  }
74
+ /** Cut `text` at `max` chars with an explicit marker carrying the full length. */
75
+ export declare function boundToolOutput(text: string, max?: number): string;
37
76
  /**
38
77
  * Claude Code CLI Connector
39
78
  * Invokes Claude Code as a subprocess for agent evaluation
40
79
  */
41
- export declare class ClaudeCodeConnector extends SubprocessConnector {
80
+ export declare class ClaudeCodeConnector extends SubprocessConnector<ClaudeCodeExecutionState> {
42
81
  readonly type: "claude-code";
43
82
  readonly name = "Claude Code CLI";
44
83
  traceContext: {
45
84
  propagateEnv: boolean;
46
85
  serviceName: string;
47
86
  };
48
- private outputBuffer;
49
- private thinkingBuffer;
50
- private textBuffer;
51
- private isInThinking;
52
- /**
53
- * Claude Code's `session_id` (present on every stream-json event). Captured
54
- * for Strategy D trace correlation — it equals the `session.id` attribute
55
- * Claude Code stamps on its OTel spans. Surfaced to the report via
56
- * {@link extraResultMetadata}.
57
- */
58
- private sessionId?;
59
- /**
60
- * The connector's pristine constructor-time args, captured on first execute.
61
- * The registry hands out a SINGLETON connector instance shared by all
62
- * concurrent benchmark tasks; building per-execution args by appending to
63
- * `this.config.args` compounded another in-flight execution's appended
64
- * config args (spawns were observed with --append-system-prompt /
65
- * --allowed-tools duplicated up to 5× at concurrency 3). Every execution
66
- * must build from this immutable base instead.
67
- */
68
- private pristineArgs?;
69
87
  constructor(config?: Partial<SubprocessConfig>);
70
88
  /**
71
89
  * Build prompt for Claude Code
72
90
  * Structures the input to get the best RCA results
73
91
  */
74
92
  buildPayload(request: ConnectorRequest): string;
93
+ protected createExecutionState(): ClaudeCodeExecutionState;
75
94
  /**
76
95
  * Parse Claude Code streaming output (stream-json format)
77
96
  * Each line is a JSON object with type and content
78
97
  */
79
- protected parseStreamingOutput(chunk: string, trajectory: TrajectoryStep[], onProgress?: ConnectorProgressCallback): void;
98
+ protected parseStreamingOutput(chunk: string, trajectory: TrajectoryStep[], onProgress: ConnectorProgressCallback | undefined, state: ClaudeCodeExecutionState): void;
80
99
  /**
81
100
  * Parse a single JSON event from stream-json output
82
101
  */
@@ -89,20 +108,34 @@ export declare class ClaudeCodeConnector extends SubprocessConnector {
89
108
  stderr: string;
90
109
  exitCode: number;
91
110
  }): TrajectoryStep[];
92
- /**
93
- * Reset state for new execution
94
- */
95
- private resetState;
96
111
  /**
97
112
  * Flush remaining buffers when the subprocess stream ends.
98
113
  */
99
- protected onBeforeStreamEnd(trajectory: TrajectoryStep[], onProgress?: ConnectorProgressCallback): void;
114
+ protected onBeforeStreamEnd(trajectory: TrajectoryStep[], onProgress: ConnectorProgressCallback | undefined, state: ClaudeCodeExecutionState): void;
100
115
  /**
101
116
  * Build CLI args from ClaudeCodeConnectorConfig
102
117
  */
103
118
  private buildConfigArgs;
104
119
  /**
105
- * Override execute to reset state and apply connectorConfig
120
+ * Translate `ClaudeCodeConnectorConfig` (the agent's `connectorConfig`) into
121
+ * the effective per-execution subprocess config. Pure: builds a fresh
122
+ * snapshot from the constructor defaults — `this.config` is never written,
123
+ * so concurrent executions on the shared singleton cannot compound each
124
+ * other's flags (spawns were once observed with --append-system-prompt /
125
+ * --allowed-tools duplicated up to 5× at concurrency 3) or swap env /
126
+ * timeout / cwd.
127
+ */
128
+ protected resolveExecutionConfig(request: ConnectorRequest): {
129
+ inputMode: import("../../../services/connectors/types.js").SubprocessInputMode;
130
+ env: Record<string, string>;
131
+ args: string[];
132
+ command: string;
133
+ outputParser: import("../../../services/connectors/types.js").SubprocessOutputParser;
134
+ timeout?: number;
135
+ workingDir?: string;
136
+ };
137
+ /**
138
+ * Override execute for debug logging around the base implementation.
106
139
  */
107
140
  execute(endpoint: string, request: ConnectorRequest, auth: ConnectorAuth, onProgress?: ConnectorProgressCallback, onRawEvent?: (event: any) => void): Promise<import('../types.js').ConnectorResponse>;
108
141
  /**
@@ -111,9 +144,11 @@ export declare class ClaudeCodeConnector extends SubprocessConnector {
111
144
  healthCheck(endpoint: string, auth: ConnectorAuth): Promise<boolean>;
112
145
  /**
113
146
  * Surface the captured Claude Code `session_id` so the runner can persist it
114
- * as `report.sessionId` for Strategy D trace correlation.
147
+ * as `report.sessionId` for Strategy D trace correlation. Read from the
148
+ * per-invocation state — never from the instance — so concurrent runs on
149
+ * the shared singleton can't swap session ids.
115
150
  */
116
- protected extraResultMetadata(): Record<string, any>;
151
+ protected extraResultMetadata(state: ClaudeCodeExecutionState): Record<string, any>;
117
152
  }
118
153
  /**
119
154
  * Create a Claude Code connector with specific Bedrock configuration
@@ -123,4 +158,5 @@ export declare function createBedrockClaudeCodeConnector(): ClaudeCodeConnector;
123
158
  * Default instance for convenience
124
159
  */
125
160
  export declare const claudeCodeConnector: ClaudeCodeConnector;
161
+ export {};
126
162
  //# sourceMappingURL=ClaudeCodeConnector.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ClaudeCodeConnector.d.ts","sourceRoot":"","sources":["../../../../../services/connectors/claude-code/ClaudeCodeConnector.ts"],"names":[],"mappings":"AAKA;;;GAGG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,sDAAsD,CAAC;AAC3F,OAAO,KAAK,EACV,aAAa,EACb,gBAAgB,EAChB,yBAAyB,EACzB,gBAAgB,EACjB,MAAM,6BAA6B,CAAC;AAErC;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9B;AAED;;;GAGG;AACH,MAAM,WAAW,yBAAyB;IACxC,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,0BAA0B,CAAC,EAAE,OAAO,CAAC;IACrC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,uEAAuE;IACvE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,yEAAyE;IACzE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CA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AO,CACpB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,gBAAgB,EACzB,IAAI,EAAE,aAAa,EACnB,UAAU,CAAC,EAAE,yBAAyB,EACtC,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,GAChC,OAAO,CAAC,OAAO,UAAU,EAAE,iBAAiB,CAAC;IAiGhD;;OAEG;IACY,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC;IAInF;;;OAGG;cACgB,mBAAmB,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;CAG9D;AAED;;GAEG;AACH,wBAAgB,gCAAgC,IAAI,mBAAmB,CA6BtE;AAED;;GAEG;AACH,eAAO,MAAM,mBAAmB,qBAA4B,CAAC"}
1
+ {"version":3,"file":"ClaudeCodeConnector.d.ts","sourceRoot":"","sources":["../../../../../services/connectors/claude-code/ClaudeCodeConnector.ts"],"names":[],"mappings":"AAKA;;;GAGG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,OAAO,EACL,mBAAmB,EACnB,KAAK,wBAAwB,EAC9B,MAAM,sDAAsD,CAAC;AAC9D,OAAO,KAAK,EACV,aAAa,EACb,gBAAgB,EAChB,yBAAyB,EACzB,gBAAgB,EACjB,MAAM,6BAA6B,CAAC;AAErC;;;;;;;;GAQG;AACH,eAAO,MAAM,iCAAiC,QAAY,CAAC;AAE3D;;;;GAIG;AACH,UAAU,wBAAyB,SAAQ,wBAAwB;IACjE,kEAAkE;IAClE,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAA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@@
3
3
  * SPDX-License-Identifier: Apache-2.0
4
4
  */
5
5
  import { ToolCallStatus } from '../../../types/index.js';
6
- import { SubprocessConnector } from '../../../services/connectors/subprocess/SubprocessConnector.js';
6
+ import { SubprocessConnector, } from '../../../services/connectors/subprocess/SubprocessConnector.js';
7
+ /**
8
+ * Upper bound on the tool output text persisted per `tool_result` step
9
+ * (`content` + `toolOutput`). Larger outputs are cut here with an explicit
10
+ * truncation marker carrying the original length, so the judge knows it saw
11
+ * a prefix. The full stream stays in `report.rawEvents`. Sized to cover the
12
+ * largest single results observed live (~28 KB) without doubling every
13
+ * report; the judge's own per-step cap (`AH_JUDGE_TOOL_OUTPUT_CAP`, default
14
+ * 100 KB) is the outer bound.
15
+ */
16
+ export const CLAUDE_CODE_MAX_TOOL_OUTPUT_CHARS = 32 * 1024;
7
17
  /**
8
18
  * Default Claude Code configuration
9
19
  *
@@ -24,6 +34,37 @@ const CLAUDE_CODE_DEFAULT_CONFIG = {
24
34
  outputParser: 'streaming',
25
35
  timeout: 600000, // 10 minutes for Claude Code
26
36
  };
37
+ /**
38
+ * Flatten a stream-json `tool_result` block into the text the model saw.
39
+ * Claude Code emits either a plain string or an array of content blocks
40
+ * (`{type:'text', text}` for MCP/Bash/Read results, `tool_reference` for
41
+ * ToolSearch, …). Text blocks are joined verbatim; anything else is
42
+ * JSON-encoded so no evidence is dropped. Falls back to the event-level
43
+ * `tool_use_result` (a structured mirror of the same result) when the block
44
+ * carries no content at all.
45
+ */
46
+ function toolResultText(block, event) {
47
+ const c = block?.content;
48
+ if (typeof c === 'string')
49
+ return c;
50
+ if (Array.isArray(c)) {
51
+ return c
52
+ .map((part) => part && part.type === 'text' && typeof part.text === 'string' ? part.text : JSON.stringify(part))
53
+ .join('\n');
54
+ }
55
+ if (c != null)
56
+ return JSON.stringify(c);
57
+ const mirror = event?.tool_use_result;
58
+ if (mirror === undefined || mirror === null)
59
+ return '';
60
+ return typeof mirror === 'string' ? mirror : JSON.stringify(mirror);
61
+ }
62
+ /** Cut `text` at `max` chars with an explicit marker carrying the full length. */
63
+ export function boundToolOutput(text, max = CLAUDE_CODE_MAX_TOOL_OUTPUT_CHARS) {
64
+ if (text.length <= max)
65
+ return text;
66
+ return `${text.slice(0, max)}\n… [tool output truncated: showing ${max} of ${text.length} chars]`;
67
+ }
27
68
  /**
28
69
  * Claude Code CLI Connector
29
70
  * Invokes Claude Code as a subprocess for agent evaluation
@@ -34,10 +75,6 @@ export class ClaudeCodeConnector extends SubprocessConnector {
34
75
  this.type = 'claude-code';
35
76
  this.name = 'Claude Code CLI';
36
77
  this.traceContext = { propagateEnv: true, serviceName: 'claude-code-agent' };
37
- this.outputBuffer = '';
38
- this.thinkingBuffer = '';
39
- this.textBuffer = '';
40
- this.isInThinking = false;
41
78
  }
42
79
  /**
43
80
  * Build prompt for Claude Code
@@ -59,22 +96,31 @@ export class ClaudeCodeConnector extends SubprocessConnector {
59
96
  parts.push(request.testCase.initialPrompt);
60
97
  return parts.join('\n');
61
98
  }
99
+ createExecutionState() {
100
+ return {
101
+ ...super.createExecutionState(),
102
+ outputBuffer: '',
103
+ thinkingBuffer: '',
104
+ textBuffer: '',
105
+ pendingToolUses: new Map(),
106
+ };
107
+ }
62
108
  /**
63
109
  * Parse Claude Code streaming output (stream-json format)
64
110
  * Each line is a JSON object with type and content
65
111
  */
66
- parseStreamingOutput(chunk, trajectory, onProgress) {
67
- this.outputBuffer += chunk;
112
+ parseStreamingOutput(chunk, trajectory, onProgress, state) {
113
+ state.outputBuffer += chunk;
68
114
  // Parse complete JSON lines (NDJSON format)
69
- const lines = this.outputBuffer.split('\n');
70
- this.outputBuffer = lines.pop() || ''; // Keep incomplete line
115
+ const lines = state.outputBuffer.split('\n');
116
+ state.outputBuffer = lines.pop() || ''; // Keep incomplete line
71
117
  for (const line of lines) {
72
118
  const trimmed = line.trim();
73
119
  if (!trimmed)
74
120
  continue;
75
121
  try {
76
122
  const event = JSON.parse(trimmed);
77
- const steps = this.parseJsonEvent(event);
123
+ const steps = this.parseJsonEvent(event, state);
78
124
  for (const step of steps) {
79
125
  trajectory.push(step);
80
126
  onProgress?.(step);
@@ -93,12 +139,12 @@ export class ClaudeCodeConnector extends SubprocessConnector {
93
139
  /**
94
140
  * Parse a single JSON event from stream-json output
95
141
  */
96
- parseJsonEvent(event) {
142
+ parseJsonEvent(event, state) {
97
143
  const steps = [];
98
144
  // Capture the session id (present on system/init, assistant, user, result
99
145
  // events). Used for Strategy D trace correlation (attributes.session.id).
100
146
  if (typeof event.session_id === 'string' && event.session_id) {
101
- this.sessionId = event.session_id;
147
+ state.sessionId = event.session_id;
102
148
  }
103
149
  // Handle different event types from Claude Code stream-json
104
150
  if (event.type === 'assistant' && event.message?.content) {
@@ -110,6 +156,9 @@ export class ClaudeCodeConnector extends SubprocessConnector {
110
156
  steps.push(this.createStep('assistant', block.text));
111
157
  }
112
158
  else if (block.type === 'tool_use') {
159
+ if (typeof block.id === 'string' && block.id) {
160
+ state.pendingToolUses.set(block.id, { name: block.name, input: block.input });
161
+ }
113
162
  steps.push(this.createStep('action', JSON.stringify(block.input || {}), {
114
163
  toolName: block.name,
115
164
  toolArgs: block.input,
@@ -122,13 +171,23 @@ export class ClaudeCodeConnector extends SubprocessConnector {
122
171
  // content blocks (referenced back to the assistant's tool_use_id).
123
172
  // Without this branch, tool outputs are silently dropped — the trajectory
124
173
  // shows the tool calls but not their results.
174
+ //
175
+ // Each result is paired with its `tool_use` by id so the step carries
176
+ // the tool name, and the (bounded) output text is stored on BOTH
177
+ // `content` and `toolOutput`. `toolOutput` is what the judge and the
178
+ // trajectory-merge policy (services/traces/trajectoryMerge.ts) treat as
179
+ // evidence; without it a span-derived "tool succeeded" stub could
180
+ // replace a 28 KB retrieval result.
125
181
  for (const block of event.message.content) {
126
182
  if (block.type === 'tool_result') {
127
- const content = typeof block.content === 'string'
128
- ? block.content
129
- : JSON.stringify(block.content);
130
- steps.push(this.createStep('tool_result', content, {
183
+ const paired = typeof block.tool_use_id === 'string' ? state.pendingToolUses.get(block.tool_use_id) : undefined;
184
+ if (paired && typeof block.tool_use_id === 'string')
185
+ state.pendingToolUses.delete(block.tool_use_id);
186
+ const output = boundToolOutput(toolResultText(block, event));
187
+ steps.push(this.createStep('tool_result', output, {
131
188
  status: block.is_error ? ToolCallStatus.FAILURE : ToolCallStatus.SUCCESS,
189
+ ...(paired?.name ? { toolName: paired.name } : {}),
190
+ ...(output ? { toolOutput: output } : {}),
132
191
  }));
133
192
  }
134
193
  else if (block.type === 'text' && block.text) {
@@ -140,23 +199,23 @@ export class ClaudeCodeConnector extends SubprocessConnector {
140
199
  else if (event.type === 'content_block_delta') {
141
200
  // Streaming delta updates — accumulate into buffers
142
201
  if (event.delta?.type === 'thinking_delta' && event.delta.thinking) {
143
- this.thinkingBuffer += event.delta.thinking;
202
+ state.thinkingBuffer += event.delta.thinking;
144
203
  }
145
204
  else if (event.delta?.type === 'text_delta' && event.delta.text) {
146
205
  // Accumulate text deltas; the 'result' event will emit the final response
147
- this.textBuffer += event.delta.text;
206
+ state.textBuffer += event.delta.text;
148
207
  }
149
208
  }
150
209
  else if (event.type === 'content_block_stop') {
151
210
  // Flush thinking buffer when block ends
152
- if (this.thinkingBuffer) {
153
- steps.push(this.createStep('thinking', this.thinkingBuffer));
154
- this.thinkingBuffer = '';
211
+ if (state.thinkingBuffer) {
212
+ steps.push(this.createStep('thinking', state.thinkingBuffer));
213
+ state.thinkingBuffer = '';
155
214
  }
156
215
  // Flush text buffer when block ends (consolidated assistant step)
157
- if (this.textBuffer) {
158
- steps.push(this.createStep('assistant', this.textBuffer));
159
- this.textBuffer = '';
216
+ if (state.textBuffer) {
217
+ steps.push(this.createStep('assistant', state.textBuffer));
218
+ state.textBuffer = '';
160
219
  }
161
220
  }
162
221
  else if (event.type === 'result' && event.result) {
@@ -193,49 +252,40 @@ export class ClaudeCodeConnector extends SubprocessConnector {
193
252
  }
194
253
  return steps;
195
254
  }
196
- /**
197
- * Reset state for new execution
198
- */
199
- resetState() {
200
- this.outputBuffer = '';
201
- this.thinkingBuffer = '';
202
- this.textBuffer = '';
203
- this.isInThinking = false;
204
- }
205
255
  /**
206
256
  * Flush remaining buffers when the subprocess stream ends.
207
257
  */
208
- onBeforeStreamEnd(trajectory, onProgress) {
258
+ onBeforeStreamEnd(trajectory, onProgress, state) {
209
259
  // Flush outputBuffer (incomplete NDJSON line)
210
- if (this.outputBuffer.trim()) {
260
+ if (state.outputBuffer.trim()) {
211
261
  try {
212
- const event = JSON.parse(this.outputBuffer.trim());
213
- const steps = this.parseJsonEvent(event);
262
+ const event = JSON.parse(state.outputBuffer.trim());
263
+ const steps = this.parseJsonEvent(event, state);
214
264
  for (const step of steps) {
215
265
  trajectory.push(step);
216
266
  onProgress?.(step);
217
267
  }
218
268
  }
219
269
  catch {
220
- const step = this.createStep('assistant', this.outputBuffer.trim());
270
+ const step = this.createStep('assistant', state.outputBuffer.trim());
221
271
  trajectory.push(step);
222
272
  onProgress?.(step);
223
273
  }
224
- this.outputBuffer = '';
274
+ state.outputBuffer = '';
225
275
  }
226
276
  // Flush thinkingBuffer
227
- if (this.thinkingBuffer) {
228
- const step = this.createStep('thinking', this.thinkingBuffer);
277
+ if (state.thinkingBuffer) {
278
+ const step = this.createStep('thinking', state.thinkingBuffer);
229
279
  trajectory.push(step);
230
280
  onProgress?.(step);
231
- this.thinkingBuffer = '';
281
+ state.thinkingBuffer = '';
232
282
  }
233
283
  // Flush textBuffer (text deltas received without a result event)
234
- if (this.textBuffer) {
235
- const step = this.createStep('response', this.textBuffer);
284
+ if (state.textBuffer) {
285
+ const step = this.createStep('response', state.textBuffer);
236
286
  trajectory.push(step);
237
287
  onProgress?.(step);
238
- this.textBuffer = '';
288
+ state.textBuffer = '';
239
289
  }
240
290
  }
241
291
  /**
@@ -273,93 +323,61 @@ export class ClaudeCodeConnector extends SubprocessConnector {
273
323
  return args;
274
324
  }
275
325
  /**
276
- * Override execute to reset state and apply connectorConfig
326
+ * Translate `ClaudeCodeConnectorConfig` (the agent's `connectorConfig`) into
327
+ * the effective per-execution subprocess config. Pure: builds a fresh
328
+ * snapshot from the constructor defaults — `this.config` is never written,
329
+ * so concurrent executions on the shared singleton cannot compound each
330
+ * other's flags (spawns were once observed with --append-system-prompt /
331
+ * --allowed-tools duplicated up to 5× at concurrency 3) or swap env /
332
+ * timeout / cwd.
277
333
  */
278
- async execute(endpoint, request, auth, onProgress, onRawEvent) {
279
- this.debug('========== execute() STARTED ==========');
280
- this.debug('Endpoint:', endpoint);
281
- this.debug('Test case:', request.testCase.name);
282
- this.debug('Config:', this['config']);
283
- this.resetState();
284
- // Capture the pristine base args once (first execution wins — constructor
285
- // args never change). See `pristineArgs` doc for why we must not snapshot
286
- // `this.config.args` per-execution under concurrency.
287
- this.pristineArgs ??= this.config.args ? [...this.config.args] : [];
288
- // Save original config for restoration after execution.
289
- // Uses structured clone for env to prevent leaking nested mutations
290
- // between consecutive executions in a benchmark run.
291
- const originalEnv = this.config.env ? structuredClone(this.config.env) : {};
292
- const originalArgs = [...this.pristineArgs];
293
- const originalInputMode = this.config.inputMode;
294
- const originalTimeout = this.config.timeout;
295
- const originalWorkingDir = this.config.workingDir;
296
- // Apply connectorConfig if provided
297
- const ccConfig = request.connectorConfig;
298
- if (ccConfig) {
299
- this.debug('Applying connectorConfig:', Object.keys(ccConfig));
300
- // Merge environment variables
301
- if (ccConfig.env) {
302
- this.config.env = { ...this.config.env, ...ccConfig.env };
303
- }
304
- // Switch input mode if requested
305
- if (ccConfig.usePromptArg) {
306
- this.config.inputMode = 'arg';
307
- }
308
- // Override timeout if specified
309
- if (ccConfig.timeout !== undefined) {
310
- this.config.timeout = ccConfig.timeout;
311
- }
312
- // Override working directory if specified
313
- if (ccConfig.workingDir) {
314
- this.config.workingDir = ccConfig.workingDir;
315
- }
316
- }
334
+ resolveExecutionConfig(request) {
335
+ const ccConfig = (request.connectorConfig || {});
336
+ const base = super.resolveExecutionConfig({
337
+ ...request,
338
+ // Only `env` / `timeout` / `workingDir` are base-shaped on the Claude
339
+ // Code config; everything else is translated to CLI flags below.
340
+ connectorConfig: {
341
+ ...(ccConfig.env ? { env: ccConfig.env } : {}),
342
+ ...(ccConfig.timeout !== undefined ? { timeout: ccConfig.timeout } : {}),
343
+ ...(ccConfig.workingDir ? { workingDir: ccConfig.workingDir } : {}),
344
+ },
345
+ });
346
+ const configArgs = this.buildConfigArgs(ccConfig);
347
+ if (configArgs.length > 0)
348
+ this.debug('Config args added:', configArgs);
349
+ let env = base.env || {};
317
350
  // When using Bedrock, clear any Anthropic API key to prevent
318
351
  // login-managed key from taking precedence and triggering a credit
319
352
  // balance check instead of routing through Bedrock.
320
- if (this.config.env?.CLAUDE_CODE_USE_BEDROCK === '1') {
321
- this.config.env = { ...this.config.env, ANTHROPIC_API_KEY: '' };
353
+ if (env.CLAUDE_CODE_USE_BEDROCK === '1') {
354
+ env = { ...env, ANTHROPIC_API_KEY: '' };
322
355
  this.debug('Bedrock mode: cleared ANTHROPIC_API_KEY to bypass credit check');
323
356
  }
324
357
  // The agent's model is owned by its agent-health.config.ts connector
325
358
  // config (env.ANTHROPIC_MODEL, or a `--model` flag in connectorConfig.args)
326
359
  // — there is no run-level / user-selected agent model. We intentionally do
327
360
  // NOT inject a model from the run here.
328
- // Build per-execution args from the PRISTINE base (never from the live
329
- // `this.config.args`, which may carry another in-flight execution's
330
- // appended config args). `super.execute()` (SubprocessConnector) reads
331
- // `this.config.args` synchronously at its very top (`const args =
332
- // this.config.args || []`, before any `await`) — traced end-to-end: there
333
- // is no `await` anywhere between this write and that read, so no other
334
- // concurrent `execute()` call can interleave in between (JS run-to-
335
- // completion semantics). This DOES depend on that base-class read staying
336
- // synchronous-before-first-await; if `SubprocessConnector.execute()` is
337
- // ever refactored to do async work before reading `config.args`, this
338
- // invariant breaks silently — the concurrency test below is the guard.
339
- if (ccConfig) {
340
- const configArgs = this.buildConfigArgs(ccConfig);
341
- this.config.args = [...this.pristineArgs, ...configArgs];
342
- if (configArgs.length > 0) {
343
- this.debug('Config args added:', configArgs);
344
- }
345
- }
346
- try {
347
- this.debug('State reset, calling super.execute()...');
348
- this.sessionId = undefined;
349
- const result = await super.execute(endpoint, request, auth, onProgress, onRawEvent);
350
- this.debug('super.execute() returned with', result.trajectory.length, 'steps');
351
- this.debug('========== execute() COMPLETED ==========');
352
- return result;
353
- }
354
- finally {
355
- // Restore config to pre-execution state. Uses deep copies to prevent
356
- // config pollution between consecutive executions in a benchmark run.
357
- this.config.env = originalEnv;
358
- this.config.args = originalArgs;
359
- this.config.inputMode = originalInputMode;
360
- this.config.timeout = originalTimeout;
361
- this.config.workingDir = originalWorkingDir;
362
- }
361
+ return {
362
+ ...base,
363
+ env,
364
+ args: [...(this.config.args || []), ...configArgs],
365
+ ...(ccConfig.usePromptArg ? { inputMode: 'arg' } : {}),
366
+ };
367
+ }
368
+ /**
369
+ * Override execute for debug logging around the base implementation.
370
+ */
371
+ async execute(endpoint, request, auth, onProgress, onRawEvent) {
372
+ this.debug('========== execute() STARTED ==========');
373
+ this.debug('Endpoint:', endpoint);
374
+ this.debug('Test case:', request.testCase.name);
375
+ if (request.connectorConfig)
376
+ this.debug('Applying connectorConfig:', Object.keys(request.connectorConfig));
377
+ const result = await super.execute(endpoint, request, auth, onProgress, onRawEvent);
378
+ this.debug('super.execute() returned with', result.trajectory.length, 'steps');
379
+ this.debug('========== execute() COMPLETED ==========');
380
+ return result;
363
381
  }
364
382
  /**
365
383
  * Health check - verify claude command exists
@@ -369,10 +387,15 @@ export class ClaudeCodeConnector extends SubprocessConnector {
369
387
  }
370
388
  /**
371
389
  * Surface the captured Claude Code `session_id` so the runner can persist it
372
- * as `report.sessionId` for Strategy D trace correlation.
390
+ * as `report.sessionId` for Strategy D trace correlation. Read from the
391
+ * per-invocation state — never from the instance — so concurrent runs on
392
+ * the shared singleton can't swap session ids.
373
393
  */
374
- extraResultMetadata() {
375
- return this.sessionId ? { sessionId: this.sessionId } : {};
394
+ extraResultMetadata(state) {
395
+ return {
396
+ ...super.extraResultMetadata(state),
397
+ ...(state.sessionId ? { sessionId: state.sessionId } : {}),
398
+ };
376
399
  }
377
400
  }
378
401
  /**