@salesforce/sfdx-agent-harness-mastra 0.88.0 → 0.90.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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,19 @@
3
3
  All notable changes to `@salesforce/sfdx-agent-harness-mastra` are documented in this file.
4
4
  Format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
5
5
 
6
+ ## [0.90.0] - 2026-09-23
7
+
8
+ ### Fixes
9
+ - **harness-mastra**: emit full llm-request body in wire-communication events (remove 256KB truncation) @W-24280587@ ([#839](https://github.com/forcedotcom/agentic-dx/pull/839))
10
+
11
+ ### Chores
12
+ - **deps**: bump @ai-sdk/provider from 4.0.4 to 4.0.14 ([#838](https://github.com/forcedotcom/agentic-dx/pull/838))
13
+
14
+ ## [0.89.0] - 2026-09-21
15
+
16
+ ### Features
17
+ - **agent-sdk,harness-mastra**: add GPT-5.6 + Claude Sonnet 5 to model registry; fix stale output caps + compaction max_tokens @W-23949616@ ([#833](https://github.com/forcedotcom/agentic-dx/pull/833))
18
+
6
19
  ## [0.88.0] - 2026-09-18
7
20
 
8
21
  ### Fixes
@@ -308,6 +308,16 @@ function applyThinkingConfig(params, model, providerHint) {
308
308
  }
309
309
  async function doGenerate(ctx, options) {
310
310
  const { client, commonParams, toolSchemas } = await buildAnthropicRequest(ctx, options);
311
+ // Clamp max_tokens to a summary-safe ceiling on this non-streaming path. The
312
+ // Anthropic SDK refuses a non-streaming request whose max_tokens implies a
313
+ // completion that could exceed 10 minutes (`calculateNonstreamingTimeout`,
314
+ // threshold ~21k tokens). doGenerate's only caller is compactThread's
315
+ // summarize() (see the note below) — a conversation summary never needs the
316
+ // model's full output budget — so a model with a large cap (Opus 4.x @ 128k,
317
+ // Sonnet 4.x @ 64k) would otherwise throw here. `Math.min` leaves a smaller
318
+ // cap untouched; any thinking budget buildAnthropicRequest applied is <= 4096,
319
+ // safely under this floor.
320
+ const summaryMaxTokens = Math.min(commonParams.max_tokens, SUMMARY_MAX_OUTPUT_TOKENS);
311
321
  // Forward the turn's AbortSignal into the SDK's RequestOptions so firing the
312
322
  // controller (POST /cancel, idle timeout, shutdown abortAll) actually aborts
313
323
  // the outbound gateway fetch, not just harness bookkeeping (W-23988781).
@@ -318,7 +328,7 @@ async function doGenerate(ctx, options) {
318
328
  // as COMPACTION_FAILED. Error classification here targets the streaming turn
319
329
  // path (8d) — a raw create() rejection propagating uncoded is correct for the
320
330
  // summarize-only path.
321
- const message = await client.messages.create({ ...commonParams, stream: false }, { signal: options.abortSignal });
331
+ const message = await client.messages.create({ ...commonParams, max_tokens: summaryMaxTokens, stream: false }, { signal: options.abortSignal });
322
332
  const content = [];
323
333
  let sawToolCalls = false;
324
334
  for (const block of message.content) {
@@ -564,6 +574,17 @@ async function doStream(ctx, options) {
564
574
  * API requires the field; Mastra leaves it unset for many turns. 4096 mirrors
565
575
  * the `@ai-sdk/anthropic` provider's default. */
566
576
  const DEFAULT_MAX_TOKENS = 4096;
577
+ /**
578
+ * Ceiling for the non-streaming summary request `doGenerate` issues for `compactThread`.
579
+ * The Anthropic SDK refuses a non-streaming request whose max_tokens implies a >10-minute
580
+ * completion — `expectedTime = 3.6e6 * maxTokens / 128000 ms`, so the guard trips above
581
+ * ~21,333 tokens. 16384 sits safely under that (~461s est., ~23% margin), stays above the
582
+ * max thinking budget (4096), and matches the historical working summary budget for the
583
+ * previous default model (Sonnet 4.6 @ 16384) — so a large per-model output cap
584
+ * (Opus 4.x @ 128k, Sonnet 4.x @ 64k) is clamped here instead of throwing. A conversation
585
+ * summary never needs more.
586
+ */
587
+ const SUMMARY_MAX_OUTPUT_TOKENS = 16384;
567
588
  /**
568
589
  * Translates a V3 `LanguageModelV3Prompt` into Anthropic's Messages API shape
569
590
  * — top-level `system` string + `MessageParam[]` of role-tagged content blocks.
@@ -280,11 +280,13 @@ export type GatewayFetchWireHooks = {
280
280
  * fetch resolution to HTTP-body terminality: an owned tee branch observes only
281
281
  * recognized assistant text deltas without blocking the provider SDK's branch.
282
282
  * Wire-communication events are best-effort: a failed body decode does NOT
283
- * prevent the call from completing. Body capture is
284
- * intentionally bounded — only requests with a JSON body shorter than 256 KB
285
- * are decoded; longer bodies are recorded as `{ truncated: true, byteLength:
286
- * <n> }` so wire-communication captures don't blow the consumer's log file
287
- * budget.
283
+ * prevent the call from completing. When a subscriber is present the request
284
+ * body is captured in full with no size cap (W-24280587) — the channel is
285
+ * opt-in and diagnostic, so fidelity wins; with no subscriber the decode is
286
+ * skipped entirely (the event is dropped by the wire bus anyway), so a
287
+ * subscriber-less production process pays no full-body parse on the hot path.
288
+ * (The streaming *response* observer separately bounds its in-memory text
289
+ * capture at `TRACE_BODY_BYTE_BUDGET`.)
288
290
  */
289
291
  export declare function createGatewayFetch(getHeaders: () => Record<string, string> | Promise<Record<string, string>>, wireHooks?: GatewayFetchWireHooks, innerFetch?: typeof fetch,
290
292
  /**
@@ -353,11 +353,13 @@ export function mapOpenAIUsage(usage) {
353
353
  * fetch resolution to HTTP-body terminality: an owned tee branch observes only
354
354
  * recognized assistant text deltas without blocking the provider SDK's branch.
355
355
  * Wire-communication events are best-effort: a failed body decode does NOT
356
- * prevent the call from completing. Body capture is
357
- * intentionally bounded — only requests with a JSON body shorter than 256 KB
358
- * are decoded; longer bodies are recorded as `{ truncated: true, byteLength:
359
- * <n> }` so wire-communication captures don't blow the consumer's log file
360
- * budget.
356
+ * prevent the call from completing. When a subscriber is present the request
357
+ * body is captured in full with no size cap (W-24280587) — the channel is
358
+ * opt-in and diagnostic, so fidelity wins; with no subscriber the decode is
359
+ * skipped entirely (the event is dropped by the wire bus anyway), so a
360
+ * subscriber-less production process pays no full-body parse on the hot path.
361
+ * (The streaming *response* observer separately bounds its in-memory text
362
+ * capture at `TRACE_BODY_BYTE_BUDGET`.)
361
363
  */
362
364
  export function createGatewayFetch(getHeaders, wireHooks, innerFetch = globalThis.fetch,
363
365
  /**
@@ -411,6 +413,13 @@ logBus) {
411
413
  const startedAt = clock.now();
412
414
  const correlationId = (wireHooks.idGenerator ?? new UUIDGenerator()).getUniqueId();
413
415
  const requestStart = performance.now();
416
+ // Decode the (now uncapped) request body ONLY when a subscriber is
417
+ // listening — mirroring the response-observer gating below. In production
418
+ // `wireHooks` is always supplied but subscribers are usually absent, and a
419
+ // real turn's body is large, so an unconditional full-body JSON.parse would
420
+ // be pure hot-path waste for a subscriber-less process (the event is dropped
421
+ // by the wire bus anyway). Fidelity for actual subscribers is unchanged.
422
+ const hasWireSubscribers = wireHooks.hasWireCommunicationSubscribers?.() ?? true;
414
423
  wireHooks.emitWireCommunication({
415
424
  type: 'llm-request',
416
425
  timestamp: startedAt,
@@ -418,7 +427,7 @@ logBus) {
418
427
  method,
419
428
  model,
420
429
  correlationId,
421
- body: tryDecodeBody(finalInit.body),
430
+ body: hasWireSubscribers ? tryDecodeBody(finalInit.body) : undefined,
422
431
  });
423
432
  try {
424
433
  const response = await innerFetch(input, finalInit);
@@ -791,10 +800,11 @@ function tryDecodeBody(body) {
791
800
  return undefined;
792
801
  if (typeof body !== 'string')
793
802
  return undefined; // Streams / FormData / Blob: skip.
794
- const byteLength = Buffer.byteLength(body, 'utf8');
795
- if (byteLength > TRACE_BODY_BYTE_BUDGET) {
796
- return { truncated: true, byteLength };
797
- }
803
+ // No size cap: the wire-communication channel is opt-in, subscriber-gated, and
804
+ // purely diagnostic — its whole point is fidelity, so emit the full request body
805
+ // (system / messages / tools) verbatim. (W-24280587; a 256 KB cap here used to
806
+ // replace large bodies with a `{ truncated, byteLength }` stub, hiding exactly
807
+ // the fields the channel exists to show.)
798
808
  try {
799
809
  const parsed = JSON.parse(body);
800
810
  return typeof parsed === 'object' && parsed !== null ? parsed : { value: parsed };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/sfdx-agent-harness-mastra",
3
- "version": "0.88.0",
3
+ "version": "0.90.0",
4
4
  "description": "Mastra-backed AgentHarness implementation for @salesforce/sfdx-agent-sdk",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -29,7 +29,7 @@
29
29
  "LICENSE.txt"
30
30
  ],
31
31
  "dependencies": {
32
- "@ai-sdk/provider": "4.0.4",
32
+ "@ai-sdk/provider": "4.0.14",
33
33
  "@anthropic-ai/bedrock-sdk": "^0.33.6",
34
34
  "@anthropic-ai/sdk": "^0.126.0",
35
35
  "@mastra/core": "^1.67.0",
@@ -42,12 +42,12 @@
42
42
  "openai": "^7.17.0"
43
43
  },
44
44
  "peerDependencies": {
45
- "@salesforce/sfdx-agent-sdk": "0.89.0"
45
+ "@salesforce/sfdx-agent-sdk": "0.91.0"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@eslint/js": "^10.0.1",
49
49
  "@salesforce/harness-conformance": "0.0.1",
50
- "@salesforce/sfdx-agent-sdk": "0.89.0",
50
+ "@salesforce/sfdx-agent-sdk": "0.91.0",
51
51
  "@types/node": "^22.20.1",
52
52
  "@vitest/coverage-istanbul": "^5.0.1",
53
53
  "@vitest/eslint-plugin": "^1.6.27",