Skip to content

Commit 6719528

Browse files
committed
docs: document runner model helpers
1 parent dea0be4 commit 6719528

14 files changed

Lines changed: 45 additions & 0 deletions

src/agents/embedded-agent-runner/manual-compaction-boundary.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/**
2+
* Hardens manual compaction transcript boundaries after explicit `/compact`.
3+
*/
14
import type { AgentMessage } from "../runtime/index.js";
25
import type { SessionEntry } from "../sessions/index.js";
36
import {
@@ -69,6 +72,7 @@ function hasMessagesToSummarizeBeforeKeptTail(params: {
6972
.some((entry) => entryCreatesCompactionInputMessage(entry));
7073
}
7174

75+
/** Rewrite the latest manual compaction leaf so replay starts from its summary. */
7276
export async function hardenManualCompactionBoundary(params: {
7377
sessionFile: string;
7478
preserveRecentTail?: boolean;

src/agents/embedded-agent-runner/message-action-discovery-input.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/**
2+
* Builds scoped message-action discovery inputs for embedded-agent tool setup.
3+
*/
14
import type { OpenClawConfig } from "../../config/types.openclaw.js";
25

36
/**
@@ -6,6 +9,7 @@ import type { OpenClawConfig } from "../../config/types.openclaw.js";
69
* Discovery expects absent optional fields as `undefined`; preserving nulls would create
710
* different cache/input shapes for the same missing runtime fact.
811
*/
12+
/** Collect the current sender/channel hints used to discover message actions. */
913
export function buildEmbeddedMessageActionDiscoveryInput(params: {
1014
cfg?: OpenClawConfig;
1115
channel: string;

src/agents/embedded-agent-runner/model-context-tokens.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/**
2+
* Reads normalized context-token metadata from resolved model definitions.
3+
*/
14
import type { Model } from "../../llm/types.js";
25

36
/**
@@ -8,6 +11,7 @@ type AgentModelWithOptionalContextTokens = Model & {
811
};
912

1013
/** Returns finite context-token metadata when a model discovery source provided it. */
14+
/** Prefer contextTokens, then contextWindow, when present on model metadata. */
1115
export function readAgentModelContextTokens(model: Model | null | undefined): number | undefined {
1216
const value = (model as AgentModelWithOptionalContextTokens | null | undefined)?.contextTokens;
1317
return typeof value === "number" && Number.isFinite(value) ? value : undefined;

src/agents/embedded-agent-runner/model-discovery-cache.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/**
2+
* Discovers cached model/provider state from configured agent stores.
3+
*/
14
import { statSync } from "node:fs";
25
import path from "node:path";
36
import type { OpenClawConfig } from "../../config/types.openclaw.js";

src/agents/embedded-agent-runner/model.inline-provider.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/**
2+
* Converts inline provider model config into runtime model definitions.
3+
*/
14
import { normalizeOptionalLowercaseString } from "@openclaw/normalization-core/string-coerce";
25
import type { ModelDefinitionConfig, ModelProviderConfig } from "../../config/types.js";
36
import { normalizeGoogleApiBaseUrl } from "../../infra/google-api-base-url.js";

src/agents/embedded-agent-runner/model.provider-normalization.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/**
2+
* Normalizes resolved provider/model ids on model records.
3+
*/
14
import type { Model } from "../../llm/types.js";
25
import { normalizeModelCompat } from "../../plugins/provider-model-compat.js";
36

src/agents/embedded-agent-runner/model.static-catalog.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/**
2+
* Resolves bundled static catalog rows for embedded-agent model selection.
3+
*/
14
import type { NormalizedModelCatalogRow } from "@openclaw/model-catalog-core/model-catalog-types";
25
import { normalizeProviderId } from "@openclaw/model-catalog-core/provider-id";
36
import type { OpenClawConfig } from "../../config/types.openclaw.js";

src/agents/embedded-agent-runner/model.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/**
2+
* Resolves embedded-agent provider/model selections from config, registry, and catalogs.
3+
*/
14
import { finiteSecondsToTimerSafeMilliseconds } from "@openclaw/normalization-core/number-coercion";
25
import type { ModelCompatConfig, ModelMediaInputConfig } from "../../config/types.models.js";
36
import type { OpenClawConfig } from "../../config/types.openclaw.js";

src/agents/embedded-agent-runner/post-compaction-loop-guard.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/**
2+
* Guards against repeated tool-loop compactions that never make progress.
3+
*/
14
import type { ToolLoopPostCompactionGuardConfig } from "../../config/types.tools.js";
25
import { createSubsystemLogger } from "../../logging/subsystem.js";
36

src/agents/embedded-agent-runner/prompt-cache-observability.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/**
2+
* Tracks prompt-cache snapshot changes for observability diagnostics.
3+
*/
14
import crypto from "node:crypto";
25
import type { NormalizedUsage } from "../usage.js";
36

0 commit comments

Comments
 (0)