@deepagents/context 7.7.2 → 7.8.1

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/README.md CHANGED
@@ -429,7 +429,7 @@ During streamed `chat()` turns, persisting that synthetic user message preserves
429
429
  the exact `tool result → synthetic user message → next assistant` prefix across
430
430
  later requests for prompt caching. Multiple tool-output and steer reminders
431
431
  firing at one boundary share one synthetic message. `once(id)` is durable for
432
- all three reminder targets. Bare `createPrepareStep()` integrations and
432
+ all three reminder targets. Bare `createReminderSession()` integrations and
433
433
  `agent.generate()` inject the reminder but own persistence of their generated
434
434
  assistant history.
435
435
 
package/dist/browser.js CHANGED
@@ -55,24 +55,37 @@ function fragment(name, ...children) {
55
55
  data: children
56
56
  };
57
57
  }
58
- function withoutDuplicateReasoningParts(message2) {
59
- const seenReasoningItemIds = /* @__PURE__ */ new Set();
60
- let dropped = false;
61
- const parts = message2.parts.filter((part) => {
62
- if (part.type !== "reasoning") return true;
63
- const itemId = part.providerMetadata?.openai?.itemId;
64
- if (typeof itemId !== "string") return true;
65
- if (seenReasoningItemIds.has(itemId)) {
66
- dropped = true;
67
- return false;
68
- }
69
- seenReasoningItemIds.add(itemId);
70
- return true;
58
+ function withReasoningItemsGrouped(message2) {
59
+ const partsByItemId = /* @__PURE__ */ new Map();
60
+ for (const part of message2.parts) {
61
+ const itemId = reasoningItemIdOf(part);
62
+ if (itemId === void 0) continue;
63
+ const itemParts = partsByItemId.get(itemId);
64
+ if (itemParts) {
65
+ itemParts.push(part);
66
+ } else {
67
+ partsByItemId.set(itemId, [part]);
68
+ }
69
+ }
70
+ if (partsByItemId.values().every((itemParts) => itemParts.length === 1)) {
71
+ return message2;
72
+ }
73
+ const parts = message2.parts.flatMap((part) => {
74
+ const itemId = reasoningItemIdOf(part);
75
+ if (itemId === void 0) return [part];
76
+ const itemParts = partsByItemId.get(itemId) ?? [];
77
+ partsByItemId.delete(itemId);
78
+ return itemParts;
71
79
  });
72
- return dropped ? { ...message2, parts } : message2;
80
+ return { ...message2, parts };
81
+ }
82
+ function reasoningItemIdOf(part) {
83
+ if (part.type !== "reasoning") return void 0;
84
+ const itemId = part.providerMetadata?.openai?.itemId;
85
+ return typeof itemId === "string" ? itemId : void 0;
73
86
  }
74
87
  function assistant(message2) {
75
- const normalized = withoutDuplicateReasoningParts(message2);
88
+ const normalized = withReasoningItemsGrouped(message2);
76
89
  return {
77
90
  id: normalized.id,
78
91
  name: "assistant",