Skip to content

Commit 57c88dd

Browse files
committed
chore: remove more unused internal helpers
1 parent 654de64 commit 57c88dd

9 files changed

Lines changed: 10 additions & 118 deletions

src/agents/agent-runtime-metadata.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,6 @@ import { resolveDefaultModelForAgent } from "./model-selection.js";
55

66
export type { AgentRuntimeMetadata };
77

8-
export function resolveAgentRuntimeMetadata(
9-
_cfg: OpenClawConfig,
10-
_agentId: string,
11-
_env: NodeJS.ProcessEnv = process.env,
12-
): AgentRuntimeMetadata {
13-
return {
14-
id: "auto",
15-
source: "implicit",
16-
};
17-
}
18-
198
export function resolveModelAgentRuntimeMetadata(params: {
209
cfg: OpenClawConfig;
2110
agentId: string;

src/agents/model-transport-debug.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,6 @@ export function isModelTransportDebugEnabled(env: ModelTransportDebugEnv = proce
5757
);
5858
}
5959

60-
export function isCodeModeDebugEnabled(env: ModelTransportDebugEnv = process.env): boolean {
61-
return isTruthyEnv(env.OPENCLAW_DEBUG_CODE_MODE) || isModelTransportDebugEnabled(env);
62-
}
63-
6460
export function emitModelTransportDebug(log: SubsystemLogger, message: string): void {
6561
if (isModelTransportDebugEnabled()) {
6662
log.info(message);

src/agents/openai-reasoning-compat.ts

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import { normalizeLowercaseStringOrEmpty } from "../shared/string-coerce.js";
2-
import { resolveOpenAIReasoningEffortForModel } from "./openai-reasoning-effort.js";
3-
42
type OpenAIReasoningCompatModel = {
53
provider?: string | null;
64
id?: string | null;
@@ -41,19 +39,3 @@ export function resolveOpenAIReasoningEffortMap(
4139
...readCompatReasoningEffortMap(model.compat),
4240
};
4341
}
44-
45-
export function mapOpenAIReasoningEffortForModel(params: {
46-
model: OpenAIReasoningCompatModel;
47-
effort?: string;
48-
fallbackMap?: Record<string, string>;
49-
}): string | undefined {
50-
const { effort } = params;
51-
if (effort === undefined) {
52-
return effort;
53-
}
54-
return resolveOpenAIReasoningEffortForModel({
55-
model: params.model,
56-
effort,
57-
fallbackMap: resolveOpenAIReasoningEffortMap(params.model, params.fallbackMap),
58-
});
59-
}

src/agents/prompt-surface.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,6 @@ import { isOpenClawMainPromptSurface } from "../plugins/agent-prompt-surface-kin
22
import type { AgentPromptSurfaceKind } from "../plugins/types.js";
33
import { isAcpSessionKey, isSubagentSessionKey } from "../routing/session-key.js";
44

5-
export type AgentPromptRenderContext = {
6-
surface: AgentPromptSurfaceKind;
7-
agentRuntimeId?: string;
8-
backendKind?: string;
9-
availableTools?: ReadonlySet<string>;
10-
sourceReplyDeliveryMode?: "automatic" | "message_tool_only";
11-
acpEnabled?: boolean;
12-
runtimeChannel?: string;
13-
runtimeCapabilities?: readonly string[];
14-
};
15-
165
export function buildOpenClawToolFallbackText(params: {
176
surface: AgentPromptSurfaceKind;
187
execToolName: string;

src/agents/queued-file-writer.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ import fs from "node:fs/promises";
22
import path from "node:path";
33
import { appendRegularFile, resolveRegularFileAppendFlags } from "../infra/fs-safe.js";
44

5-
export type QueuedFileWriteResult = "queued" | "dropped";
6-
75
export type QueuedFileWriterDiagnostics = {
86
pendingWrites: number;
97
queuedBytes: number;

src/agents/subagent-control.ts

Lines changed: 3 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
import crypto from "node:crypto";
22
import type { ClearSessionQueueResult } from "../auto-reply/reply/queue.js";
3-
import {
4-
resolveSubagentLabel,
5-
resolveSubagentTargetFromRuns,
6-
sortSubagentRuns,
7-
type SubagentTargetResolution,
8-
} from "../auto-reply/reply/subagents-utils.js";
3+
import { resolveSubagentLabel, sortSubagentRuns } from "../auto-reply/reply/subagents-utils.js";
94
import { resolveStorePath } from "../config/sessions/paths.js";
105
import { loadSessionStore, updateSessionStore } from "../config/sessions/store.js";
116
import type { SessionEntry } from "../config/sessions/types.js";
@@ -41,7 +36,6 @@ import { resolveInternalSessionKey, resolveMainSessionAlias } from "./tools/sess
4136

4237
export const DEFAULT_RECENT_MINUTES = 30;
4338
export const MAX_RECENT_MINUTES = 24 * 60;
44-
export const MAX_STEER_MESSAGE_CHARS = 4_000;
4539
const STEER_RATE_LIMIT_MS = 2_000;
4640
const STEER_ABORT_SETTLE_TIMEOUT_MS = 5_000;
4741
const SUBAGENT_REPLY_HISTORY_LIMIT = 50;
@@ -154,15 +148,8 @@ function ensureControllerOwnsRun(params: {
154148
return "Subagents can only control runs spawned from their own session.";
155149
}
156150

157-
function isFinishedForSteerControl(
158-
entry: SubagentRunRecord,
159-
hasPendingDescendants: boolean,
160-
) {
161-
return (
162-
Boolean(entry.endedAt) &&
163-
entry.pauseReason !== "sessions_yield" &&
164-
!hasPendingDescendants
165-
);
151+
function isFinishedForSteerControl(entry: SubagentRunRecord, hasPendingDescendants: boolean) {
152+
return Boolean(entry.endedAt) && entry.pauseReason !== "sessions_yield" && !hasPendingDescendants;
166153
}
167154

168155
async function killSubagentRun(params: {
@@ -717,30 +704,6 @@ export async function sendControlledSubagentMessage(params: {
717704
}
718705
}
719706

720-
export function resolveControlledSubagentTarget(
721-
runs: SubagentRunRecord[],
722-
token: string | undefined,
723-
options?: { recentMinutes?: number; isActive?: (entry: SubagentRunRecord) => boolean },
724-
): SubagentTargetResolution {
725-
return resolveSubagentTargetFromRuns({
726-
runs,
727-
token,
728-
recentWindowMinutes: options?.recentMinutes ?? DEFAULT_RECENT_MINUTES,
729-
label: (entry) => resolveSubagentLabel(entry),
730-
aliases: (entry) => (entry.taskName ? [entry.taskName] : []),
731-
isActive: options?.isActive,
732-
errors: {
733-
missingTarget: "Missing subagent target.",
734-
invalidIndex: (value) => `Invalid subagent index: ${value}`,
735-
unknownSession: (value) => `Unknown subagent session: ${value}`,
736-
ambiguousLabel: (value) => `Ambiguous subagent label: ${value}`,
737-
ambiguousLabelPrefix: (value) => `Ambiguous subagent label prefix: ${value}`,
738-
ambiguousRunIdPrefix: (value) => `Ambiguous subagent run id prefix: ${value}`,
739-
unknownTarget: (value) => `Unknown subagent target: ${value}`,
740-
},
741-
});
742-
}
743-
744707
export const testing = {
745708
setDepsForTest(
746709
overrides?: Partial<{

src/commands/sessions.acp-runtime-metadata.test.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import { parseAgentSessionKey } from "../routing/session-key.js";
55

66
/**
77
* Catalog #18 — `openclaw sessions --json` reports `agentRuntime.id: "openclaw"` for
8-
* ACP sessions because `resolveAgentRuntimeMetadata` only consults agent-config
8+
* ACP sessions because the old metadata resolver only consulted agent-config
99
* policies (env / agent / defaults / implicit fallback to "openclaw"). The session
1010
* key clearly carries the ACP runtime indicator (the `:acp:` segment), but
11-
* `sessions.ts:294` ignores it and just calls `resolveAgentRuntimeMetadata(cfg, agentId)`.
11+
* `sessions.ts:294` used to ignore it.
1212
*
1313
* Empirical observation from a deployed openclaw container against a copilot
1414
* agent that has no explicit `agentRuntime.id` policy:
@@ -38,9 +38,7 @@ import { parseAgentSessionKey } from "../routing/session-key.js";
3838
* The fix likely belongs at the caller (sessions.ts:294 and the other
3939
* call sites in `src/gateway/server-methods/sessions.ts`,
4040
* `src/gateway/session-utils.ts`) so it can pass session-key context to
41-
* `resolveAgentRuntimeMetadata`, OR `resolveAgentRuntimeMetadata` itself
42-
* gains an optional `sessionKey` parameter and applies a session-key-aware
43-
* override.
41+
* `resolveModelAgentRuntimeMetadata`.
4442
*/
4543

4644
const ACP_SESSION_KEY = "agent:copilot:acp:86b7b5af-3773-4a56-b244-069d6c5d3db9";
@@ -52,8 +50,8 @@ const NON_ACP_SESSION_KEY = "agent:main:main";
5250
* - it has NO explicit `agentRuntime.id` policy
5351
* - no top-level `agents.defaults.agentRuntime` either
5452
*
55-
* Result: `resolveAgentRuntimeMetadata(cfg, "copilot")` falls through to the
56-
* implicit "openclaw" branch — which is the bug under test.
53+
* Result: the old metadata resolver fell through to the implicit "openclaw"
54+
* branch — which is the bug under test.
5755
*/
5856
function buildConfigWithoutAgentRuntimePolicy(): OpenClawConfig {
5957
return {
@@ -79,8 +77,7 @@ function buildConfigWithoutAgentRuntimePolicy(): OpenClawConfig {
7977
* const agentRuntime = resolveModelAgentRuntimeMetadata({ cfg, agentId, sessionKey: row.key });
8078
*
8179
* Returns the same shape that ends up serialized to `--json` output.
82-
* After commit 02fe0d8978, the production path goes through resolveModelAgentRuntimeMetadata
83-
* (not resolveAgentRuntimeMetadata which is now a stub returning { id: "auto", source: "implicit" }).
80+
* After commit 02fe0d8978, the production path goes through resolveModelAgentRuntimeMetadata.
8481
*/
8582
function computeSessionAgentRuntime(params: {
8683
cfg: OpenClawConfig;
@@ -170,7 +167,7 @@ describe("sessions --json agentRuntime classifier (catalog #18)", () => {
170167
`ACP session ${ACP_SESSION_KEY} should resolve to runtime id "acpx" (or the canonical ACP runtime label). ` +
171168
`Got "${agentRuntime.id}". Fix candidates: ` +
172169
`(a) override at the call site in src/commands/sessions.ts:294 once isAcpSessionKey(row.key) is true, or ` +
173-
`(b) extend resolveAgentRuntimeMetadata to accept an optional sessionKey and apply the override centrally.`,
170+
`make resolveModelAgentRuntimeMetadata apply the session-key-aware override centrally.`,
174171
).toBe("acpx");
175172
});
176173

src/logging/diagnostic-session-recovery.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,6 @@ import type {
33
DiagnosticSessionState,
44
} from "../infra/diagnostic-events.js";
55

6-
export type DiagnosticSessionRecoveryStatus =
7-
| "aborted"
8-
| "released"
9-
| "skipped"
10-
| "noop"
11-
| "failed";
12-
136
export type DiagnosticSessionRecoverySkipReason =
147
| "active_embedded_run"
158
| "active_reply_work"

src/media/test-helpers.ts

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)