graphlit-client 1.0.20260419004 → 1.0.20260420001

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/dist/client.d.ts CHANGED
@@ -3133,6 +3133,18 @@ declare class Graphlit {
3133
3133
  * arg. Convenience wrapper over `extractTaskCompleteFinalMessage`.
3134
3134
  */
3135
3135
  private extractTaskCompleteFinalMessageFromMessages;
3136
+ /**
3137
+ * Sanitize task_complete's `final_message` payload out of persisted
3138
+ * intermediate messages. The tool call record (name, id, timing, ordering)
3139
+ * is preserved as a completion marker, but its `final_message` arg is
3140
+ * stripped because that content is already stored as the turn's assistant
3141
+ * text via `completion`. Keeping the tool call without the payload yields
3142
+ * the same storage win as full removal while preserving the trace.
3143
+ *
3144
+ * Handles both direct and meta-executor (`execute_tool({tool: ...})`)
3145
+ * invocations, matching `detectTaskComplete`.
3146
+ */
3147
+ private sanitizeTaskCompletePayload;
3136
3148
  /**
3137
3149
  * Run LLM-as-judge quality assessment on a completed agent run.
3138
3150
  */
package/dist/client.js CHANGED
@@ -7305,8 +7305,15 @@ class Graphlit {
7305
7305
  return undefined;
7306
7306
  return `PT${ms / 1000}S`;
7307
7307
  };
7308
- let turnMessageInputs = loopResult.intermediateMessages.length > 0
7309
- ? loopResult.intermediateMessages
7308
+ // Sanitize task_complete's final_message arg before persistence —
7309
+ // the content is already saved as the turn's assistant text, so
7310
+ // keeping it in the tool-call arguments would double-store it.
7311
+ // The tool call record itself stays as a completion marker.
7312
+ const sanitizedIntermediates = taskCompleteThisTurn
7313
+ ? this.sanitizeTaskCompletePayload(loopResult.intermediateMessages)
7314
+ : loopResult.intermediateMessages;
7315
+ let turnMessageInputs = sanitizedIntermediates.length > 0
7316
+ ? sanitizedIntermediates
7310
7317
  : undefined;
7311
7318
  if (loopResult.lastRoundReasoning) {
7312
7319
  const completionInput = {
@@ -7671,6 +7678,57 @@ class Graphlit {
7671
7678
  }
7672
7679
  return undefined;
7673
7680
  }
7681
+ /**
7682
+ * Sanitize task_complete's `final_message` payload out of persisted
7683
+ * intermediate messages. The tool call record (name, id, timing, ordering)
7684
+ * is preserved as a completion marker, but its `final_message` arg is
7685
+ * stripped because that content is already stored as the turn's assistant
7686
+ * text via `completion`. Keeping the tool call without the payload yields
7687
+ * the same storage win as full removal while preserving the trace.
7688
+ *
7689
+ * Handles both direct and meta-executor (`execute_tool({tool: ...})`)
7690
+ * invocations, matching `detectTaskComplete`.
7691
+ */
7692
+ sanitizeTaskCompletePayload(messages) {
7693
+ return messages.map((msg) => {
7694
+ if (!msg.toolCalls || msg.toolCalls.length === 0)
7695
+ return msg;
7696
+ let mutated = false;
7697
+ const sanitizedToolCalls = msg.toolCalls.map((tc) => {
7698
+ if (!tc || !tc.arguments)
7699
+ return tc;
7700
+ let args;
7701
+ try {
7702
+ args = JSON.parse(tc.arguments);
7703
+ }
7704
+ catch {
7705
+ return tc;
7706
+ }
7707
+ // Direct invocation: args ARE the task_complete params
7708
+ if (tc.name === "task_complete" && "final_message" in args) {
7709
+ const { final_message: _dropped, ...rest } = args;
7710
+ void _dropped;
7711
+ mutated = true;
7712
+ return { ...tc, arguments: JSON.stringify(rest) };
7713
+ }
7714
+ // Meta-executor wrapping: { tool: "task_complete", parameters: {...} }
7715
+ if (args.tool === "task_complete") {
7716
+ const params = args.parameters;
7717
+ if (params && "final_message" in params) {
7718
+ const { final_message: _dropped, ...restParams } = params;
7719
+ void _dropped;
7720
+ mutated = true;
7721
+ return {
7722
+ ...tc,
7723
+ arguments: JSON.stringify({ ...args, parameters: restParams }),
7724
+ };
7725
+ }
7726
+ }
7727
+ return tc;
7728
+ });
7729
+ return mutated ? { ...msg, toolCalls: sanitizedToolCalls } : msg;
7730
+ });
7731
+ }
7674
7732
  /**
7675
7733
  * Run LLM-as-judge quality assessment on a completed agent run.
7676
7734
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "graphlit-client",
3
- "version": "1.0.20260419004",
3
+ "version": "1.0.20260420001",
4
4
  "description": "Graphlit API Client for TypeScript",
5
5
  "type": "module",
6
6
  "main": "./dist/client.js",