fix(driveragent): prefix thinking tokens with [THINKING] when forwarding streaming chunks to onToken

This commit is contained in:
2026-01-20 03:10:53 +00:00
parent 8bcf3257e2
commit 79efe8f6b8
3 changed files with 23 additions and 7 deletions

View File

@@ -1,5 +1,13 @@
# Changelog
## 2026-01-20 - 1.5.3 - fix(driveragent)
prefix thinking tokens with [THINKING] when forwarding streaming chunks to onToken
- Wraps chunk.thinking with '[THINKING] ' before calling onToken to mark thinking tokens
- Forwards chunk.content unchanged
- Change applied in ts/smartagent.classes.driveragent.ts for both initial and subsequent assistant streaming responses
- No API signature changes; only the token payloads sent to onToken are altered
## 2026-01-20 - 1.5.2 - fix()
no changes in this diff; nothing to release

View File

@@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@push.rocks/smartagent',
version: '1.5.2',
version: '1.5.3',
description: 'an agentic framework built on top of @push.rocks/smartai'
}

View File

@@ -491,10 +491,14 @@ Your complete output here
images: images,
tools: tools.length > 0 ? tools : undefined,
},
// Pass onToken callback through onChunk for streaming
// Pass onToken callback through onChunk for streaming with thinking markers
this.onToken ? (chunk: any) => {
if (chunk.thinking && this.onToken) this.onToken(chunk.thinking);
if (chunk.content && this.onToken) this.onToken(chunk.content);
if (chunk.thinking && this.onToken) {
this.onToken(`[THINKING] ${chunk.thinking}`);
}
if (chunk.content && this.onToken) {
this.onToken(chunk.content);
}
} : undefined
);
@@ -574,10 +578,14 @@ Your complete output here
messageHistory: historyForChat,
tools: tools.length > 0 ? tools : undefined,
},
// Pass onToken callback through onChunk for streaming
// Pass onToken callback through onChunk for streaming with thinking markers
this.onToken ? (chunk: any) => {
if (chunk.thinking && this.onToken) this.onToken(chunk.thinking);
if (chunk.content && this.onToken) this.onToken(chunk.content);
if (chunk.thinking && this.onToken) {
this.onToken(`[THINKING] ${chunk.thinking}`);
}
if (chunk.content && this.onToken) {
this.onToken(chunk.content);
}
} : undefined
);