@yeaft/webchat-agent 1.0.339 → 1.0.340

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.
@@ -1 +1 @@
1
- {"version":"1.0.339"}
1
+ {"version":"1.0.340"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yeaft/webchat-agent",
3
- "version": "1.0.339",
3
+ "version": "1.0.340",
4
4
  "description": "Remote worker agent for Yeaft Web Code Agent — connects the native Yeaft engine, CLI providers, and workbench tools",
5
5
  "main": "index.js",
6
6
  "type": "module",
package/yeaft/engine.js CHANGED
@@ -3437,24 +3437,28 @@ export class Engine {
3437
3437
 
3438
3438
  // If new user input was appended while this loop was streaming and
3439
3439
  // there are no tools to force another loop, splice it now and continue
3440
- // instead of ending the thread. This preserves token streaming and
3441
- // still only mutates messages at a clean loop boundary.
3442
- const appendedAfterAssistant = this.#drainPendingUserMessages(drainPendingUserMessages);
3443
- if (appendedAfterAssistant.length > 0) {
3444
- for (const item of appendedAfterAssistant) {
3445
- this.#persistAppendedUserMessage(item, runtimeSessionId);
3446
- conversationMessages.push({ role: 'user', content: item.content });
3447
- yield {
3448
- type: 'user_append',
3449
- turnId: queryTurnId,
3450
- loopNumber: turnNumber,
3451
- threadId,
3452
- preview: String(item.preview || '').slice(0, 200),
3453
- internal: Boolean(item.internal),
3454
- };
3440
+ // instead of ending the thread. A tool response must execute first: an
3441
+ // append between assistant(toolCalls) and its tool results would break
3442
+ // the provider protocol and discard the entire tool batch. The regular
3443
+ // pre-stream drain on the next iteration appends input after those results.
3444
+ if (toolCalls.length === 0) {
3445
+ const appendedAfterAssistant = this.#drainPendingUserMessages(drainPendingUserMessages);
3446
+ if (appendedAfterAssistant.length > 0) {
3447
+ for (const item of appendedAfterAssistant) {
3448
+ this.#persistAppendedUserMessage(item, runtimeSessionId);
3449
+ conversationMessages.push({ role: 'user', content: item.content });
3450
+ yield {
3451
+ type: 'user_append',
3452
+ turnId: queryTurnId,
3453
+ loopNumber: turnNumber,
3454
+ threadId,
3455
+ preview: String(item.preview || '').slice(0, 200),
3456
+ internal: Boolean(item.internal),
3457
+ };
3458
+ }
3459
+ yield { type: 'turn_end', turnNumber, stopReason: 'user_append_continue', threadId };
3460
+ continue;
3455
3461
  }
3456
- yield { type: 'turn_end', turnNumber, stopReason: 'user_append_continue', threadId };
3457
- continue;
3458
3462
  }
3459
3463
 
3460
3464
  // If no tool calls, we're done — UNLESS we still own a pending