mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-28 18:33:37 +00:00
Fix status subagent ownership parity
This commit is contained in:
@@ -160,4 +160,22 @@ describe("buildStatusReply subagent summary", () => {
|
||||
expect(reply?.text).not.toContain("🤖 Subagents: 1 active");
|
||||
expect(reply?.text).not.toContain("stale old parent child");
|
||||
});
|
||||
|
||||
it("counts controller-owned runs even when the latest child requester differs", async () => {
|
||||
addSubagentRunForTests({
|
||||
runId: "run-status-controller-owned",
|
||||
childSessionKey: "agent:main:subagent:status-controller-owned",
|
||||
requesterSessionKey: "agent:main:requester-only",
|
||||
requesterDisplayKey: "requester-only",
|
||||
controllerSessionKey: "agent:main:main",
|
||||
task: "controller-owned status worker",
|
||||
cleanup: "keep",
|
||||
createdAt: Date.now() - 60_000,
|
||||
startedAt: Date.now() - 60_000,
|
||||
});
|
||||
|
||||
const reply = await buildStatusReplyForTest({});
|
||||
|
||||
expect(reply?.text).toContain("🤖 Subagents: 1 active");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -6,11 +6,8 @@ import {
|
||||
} from "../../agents/agent-scope.js";
|
||||
import { resolveFastModeState } from "../../agents/fast-mode.js";
|
||||
import { resolveModelAuthLabel } from "../../agents/model-auth-label.js";
|
||||
import {
|
||||
countPendingDescendantRuns,
|
||||
getLatestSubagentRunByChildSessionKey,
|
||||
listSubagentRunsForRequester,
|
||||
} from "../../agents/subagent-registry.js";
|
||||
import { listControlledSubagentRuns } from "../../agents/subagent-control.js";
|
||||
import { countPendingDescendantRuns } from "../../agents/subagent-registry.js";
|
||||
import {
|
||||
resolveInternalSessionKey,
|
||||
resolveMainSessionAlias,
|
||||
@@ -32,7 +29,7 @@ import type { ElevatedLevel, ReasoningLevel, ThinkLevel, VerboseLevel } from "..
|
||||
import type { ReplyPayload } from "../types.js";
|
||||
import type { CommandContext } from "./commands-types.js";
|
||||
import { getFollowupQueueDepth, resolveQueueSettings } from "./queue.js";
|
||||
import { resolveSubagentLabel, sortSubagentRuns } from "./subagents-utils.js";
|
||||
import { resolveSubagentLabel } from "./subagents-utils.js";
|
||||
|
||||
// Some usage endpoints only work with CLI/session OAuth tokens, not API keys.
|
||||
// Skip those probes when the active auth mode cannot satisfy the endpoint.
|
||||
@@ -190,19 +187,7 @@ export async function buildStatusReply(params: {
|
||||
if (sessionKey) {
|
||||
const { mainKey, alias } = resolveMainSessionAlias(cfg);
|
||||
const requesterKey = resolveInternalSessionKey({ key: sessionKey, alias, mainKey });
|
||||
const seenChildSessionKeys = new Set<string>();
|
||||
const runs = sortSubagentRuns(listSubagentRunsForRequester(requesterKey)).filter((entry) => {
|
||||
if (seenChildSessionKeys.has(entry.childSessionKey)) {
|
||||
return false;
|
||||
}
|
||||
const latest = getLatestSubagentRunByChildSessionKey(entry.childSessionKey);
|
||||
const latestRequesterSessionKey = latest?.requesterSessionKey?.trim();
|
||||
if (!latest || latest.runId !== entry.runId || latestRequesterSessionKey !== requesterKey) {
|
||||
return false;
|
||||
}
|
||||
seenChildSessionKeys.add(entry.childSessionKey);
|
||||
return true;
|
||||
});
|
||||
const runs = listControlledSubagentRuns(requesterKey);
|
||||
const verboseEnabled = resolvedVerboseLevel && resolvedVerboseLevel !== "off";
|
||||
if (runs.length > 0) {
|
||||
const active = runs.filter(
|
||||
|
||||
Reference in New Issue
Block a user