Skip to content

Commit c008b88

Browse files
committed
Remove <think> tags in context pruned summary
1 parent 2cd3bc2 commit c008b88

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

.agents/context-pruner.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -390,9 +390,12 @@ const definition: AgentDefinition = {
390390
if (Array.isArray(message.content)) {
391391
for (const part of message.content) {
392392
if (part.type === 'text' && typeof part.text === 'string') {
393-
const text = (part.text as string).trim()
394-
if (text) {
395-
textParts.push(text)
393+
// Remove <think> tags and their contents before summarizing
394+
const textWithoutThinkTags = (part.text as string)
395+
.replace(/<think>[\s\S]*?<\/think>/g, '')
396+
.trim()
397+
if (textWithoutThinkTags) {
398+
textParts.push(textWithoutThinkTags)
396399
}
397400
} else if (part.type === 'tool-call') {
398401
const toolName = part.toolName as string

0 commit comments

Comments
 (0)