@yeaft/webchat-agent 0.1.918 → 0.1.919
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/package.json +1 -1
- package/yeaft/snapshot-filter.js +13 -5
- package/yeaft/web-bridge.js +7 -5
package/package.json
CHANGED
package/yeaft/snapshot-filter.js
CHANGED
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
*
|
|
17
17
|
* Why this exists separately from the disk replay path:
|
|
18
18
|
* `web-bridge.js` builds an in-memory `baseSnapshot` for every running
|
|
19
|
-
* VP turn. Before this filter the snapshot was
|
|
20
|
-
*
|
|
21
|
-
*
|
|
19
|
+
* VP turn. Before this filter the snapshot was unfiltered and leaked
|
|
20
|
+
* other VPs' tool calls + thinking blocks into the next turn's
|
|
21
|
+
* messages, producing orphan `tool_use` ids and Anthropic 422s.
|
|
22
22
|
* The disk path uses `ConversationStore.loadSessionHistoryForVp` —
|
|
23
23
|
* the same rules implemented here, but reading from `messages/*.md`
|
|
24
24
|
* instead of the in-memory tape. We intentionally duplicate the rule
|
|
@@ -27,8 +27,16 @@
|
|
|
27
27
|
*
|
|
28
28
|
* Pure function; does not mutate inputs.
|
|
29
29
|
*
|
|
30
|
-
* @param {object[]} snapshot — entries from getOrCreateSessionHistory(sessionId)
|
|
31
|
-
*
|
|
30
|
+
* @param {object[]} snapshot — entries from getOrCreateSessionHistory(sessionId).
|
|
31
|
+
* The caller MUST NOT pre-filter by `threadId`:
|
|
32
|
+
* threads represent intra-VP concurrent tasks,
|
|
33
|
+
* not isolated conversations, and the LLM needs
|
|
34
|
+
* every prior thread's text for continuity.
|
|
35
|
+
* (See the rationale block in
|
|
36
|
+
* `web-bridge.js#ensureDriverRunning`; pre-fix,
|
|
37
|
+
* a `m.threadId === current` filter dropped
|
|
38
|
+
* every prior thread and the LLM saw a 1-message
|
|
39
|
+
* context for every turn after the first.)
|
|
32
40
|
* @param {string} vpId — the VP we're about to send a turn for
|
|
33
41
|
* @returns {object[]}
|
|
34
42
|
*/
|
package/yeaft/web-bridge.js
CHANGED
|
@@ -1053,12 +1053,14 @@ function ensureDriverRunning(sessionId, vpId, threadId = 'main') {
|
|
|
1053
1053
|
vpAborts.set(key, vpAbort);
|
|
1054
1054
|
turnAbortCtrls.set(turnId, vpAbort);
|
|
1055
1055
|
turnAbortMeta.set(turnId, { sessionId, vpId, threadId: thread.threadId, key });
|
|
1056
|
+
// History snapshot covers EVERY prior thread of the session.
|
|
1057
|
+
// Threads represent intra-VP concurrent tasks, not isolated
|
|
1058
|
+
// conversations, so the LLM needs cross-thread continuity.
|
|
1059
|
+
// VP isolation lives in `filterSnapshotForVp`; tool_use/result
|
|
1060
|
+
// pairing lives in `pairSanitize`. Mirrors disk-side
|
|
1061
|
+
// `loadSessionHistoryForVp`, which applies no threadId filter.
|
|
1056
1062
|
const baseSnapshot = pairSanitize(
|
|
1057
|
-
filterSnapshotForVp(
|
|
1058
|
-
getOrCreateSessionHistory(sessionId)
|
|
1059
|
-
.filter((m) => !m.threadId || m.threadId === 'main' || m.threadId === thread.threadId),
|
|
1060
|
-
vpId,
|
|
1061
|
-
),
|
|
1063
|
+
filterSnapshotForVp(getOrCreateSessionHistory(sessionId), vpId),
|
|
1062
1064
|
);
|
|
1063
1065
|
const trigger = envelope?.trigger || 'fallback';
|
|
1064
1066
|
const { text, prompt, promptParts } = buildVpPromptPayload(vpId, envelope);
|