Skip to content

Commit 6aa7e87

Browse files
extracting token count from uid marker
1 parent 03f4fd6 commit 6aa7e87

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/messages/utils.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,9 @@ export function annotateContext(messages: WithParts[]): void {
294294
if (part.type !== "tool") continue
295295
uid++
296296
const tokens = countToolTokens(part)
297-
const tag = tokens > 0 ? `[uid_${uid}, ${formatTokenCount(tokens)}]` : `[uid_${uid}]`
297+
const uidTag = `[uid_${uid}]`
298+
const tokenTag = tokens > 0 ? ` [${formatTokenCount(tokens)}]` : ""
299+
const tag = `${uidTag}${tokenTag}`
298300
if (part.state?.status === "completed" && typeof part.state.output === "string") {
299301
part.state.output = `${tag}\n${part.state.output}`
300302
} else if (part.state?.status === "error" && typeof part.state.error === "string") {

0 commit comments

Comments
 (0)