mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-16 20:40:45 +00:00
fix: scope /kill <id> to current session subtree and preserve usage.cost in chat.history
- Restrict /kill <id> matching to only subagents belonging to the current session's agent subtree (P1 review feedback) - Preserve nested usage.cost in chat.history sanitization so cost badges remain available (P2 review feedback)
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -121,3 +121,4 @@ dist/protocol.schema.json
|
||||
|
||||
# Synthing
|
||||
**/.stfolder/
|
||||
openclaw
|
||||
|
||||
@@ -352,6 +352,14 @@ function sanitizeUsage(raw: unknown): Record<string, number> | undefined {
|
||||
}
|
||||
}
|
||||
|
||||
// Preserve nested usage.cost when present
|
||||
if ("cost" in u && u.cost != null && typeof u.cost === "object") {
|
||||
const sanitizedCost = sanitizeCost(u.cost);
|
||||
if (sanitizedCost) {
|
||||
(out as Record<string, unknown>).cost = sanitizedCost;
|
||||
}
|
||||
}
|
||||
|
||||
return Object.keys(out).length > 0 ? out : undefined;
|
||||
}
|
||||
|
||||
|
||||
@@ -354,10 +354,10 @@ function resolveKillTargets(
|
||||
const isMatch =
|
||||
(normalizedTarget === "all" && belongsToCurrentSession) ||
|
||||
normalizedKey === normalizedTarget ||
|
||||
(parsed?.agentId ?? "") === normalizedTarget ||
|
||||
normalizedKey.endsWith(`:subagent:${normalizedTarget}`) ||
|
||||
normalizedKey === `subagent:${normalizedTarget}` ||
|
||||
(belongsToCurrentSession && normalizedKey.endsWith(`:subagent:${normalizedTarget}`));
|
||||
(belongsToCurrentSession &&
|
||||
((parsed?.agentId ?? "") === normalizedTarget ||
|
||||
normalizedKey.endsWith(`:subagent:${normalizedTarget}`) ||
|
||||
normalizedKey === `subagent:${normalizedTarget}`));
|
||||
if (isMatch) {
|
||||
keys.add(key);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user