fix(agent): mark truncated summary fields explicitly
This commit is contained in:
parent
d49183b6ab
commit
063174b793
1 changed files with 10 additions and 2 deletions
|
|
@ -1249,7 +1249,7 @@ func formatMessageForSummary(msg providers.Message) []string {
|
||||||
"assistant(tool_call id=%s name=%s): %s",
|
"assistant(tool_call id=%s name=%s): %s",
|
||||||
tc.ID,
|
tc.ID,
|
||||||
name,
|
name,
|
||||||
utils.Truncate(args, 240),
|
truncateSummaryField(args, 240),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1266,7 +1266,7 @@ func formatMessageForSummary(msg providers.Message) []string {
|
||||||
if content == "" {
|
if content == "" {
|
||||||
return []string{fmt.Sprintf("tool(%s):", toolID)}
|
return []string{fmt.Sprintf("tool(%s):", toolID)}
|
||||||
}
|
}
|
||||||
return []string{fmt.Sprintf("tool(%s): %s", toolID, utils.Truncate(content, 320))}
|
return []string{fmt.Sprintf("tool(%s): %s", toolID, truncateSummaryField(content, 320))}
|
||||||
|
|
||||||
case "user":
|
case "user":
|
||||||
fallthrough
|
fallthrough
|
||||||
|
|
@ -1275,6 +1275,14 @@ func formatMessageForSummary(msg providers.Message) []string {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func truncateSummaryField(content string, max int) string {
|
||||||
|
truncated := utils.Truncate(content, max)
|
||||||
|
if utf8.RuneCountInString(truncated) < utf8.RuneCountInString(content) {
|
||||||
|
return truncated + " [TRUNCATED]"
|
||||||
|
}
|
||||||
|
return truncated
|
||||||
|
}
|
||||||
|
|
||||||
// estimateTokens estimates the number of tokens in a message list.
|
// estimateTokens estimates the number of tokens in a message list.
|
||||||
// Uses a safe heuristic of 2.5 characters per token to account for CJK and other
|
// Uses a safe heuristic of 2.5 characters per token to account for CJK and other
|
||||||
// overheads better than the previous 3 chars/token.
|
// overheads better than the previous 3 chars/token.
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue