refactor: move usage cost cache into agent database (#106051)

* refactor(infra): rename usage cache lock owner field

* refactor(state): migrate usage cost cache to SQLite

* fix(state): satisfy SQLite migration gates

* refactor(state): keep usage cache access synchronous

* chore: leave release notes to release workflow

* fix(state): satisfy dependency export gate
This commit is contained in:
Peter Steinberger
2026-07-12 22:39:54 -07:00
committed by GitHub
parent 8c7f3d087f
commit db252ac417
12 changed files with 598 additions and 391 deletions
-13
View File
@@ -1,11 +1,9 @@
// Runs commitment extraction, scheduling, and follow-up lifecycle work.
import { randomUUID } from "node:crypto";
import path from "node:path";
import { resolveExpiresAtMsFromDurationMs } from "@openclaw/normalization-core/number-coercion";
import { normalizeOptionalString } from "@openclaw/normalization-core/string-coerce";
import { resolveAgentWorkspaceDir } from "../agents/agent-scope.js";
import type { OpenClawConfig } from "../config/config.js";
import { resolveStateDir } from "../config/paths.js";
import { createSubsystemLogger } from "../logging/subsystem.js";
import { resolveCommitmentTimezone, resolveCommitmentsConfig } from "./config.js";
import {
@@ -211,16 +209,6 @@ function openTerminalFailureCooldown(
});
}
function resolveExtractionSessionFile(agentId: string, runId: string): string {
return path.join(
resolveStateDir(),
"commitments",
"extractor-sessions",
agentId,
`${runId}.jsonl`,
);
}
function joinPayloadText(result: EmbeddedAgentPayloadResult): string {
return (
result.payloads
@@ -260,7 +248,6 @@ async function defaultExtractBatch(params: {
sessionKey: `agent:${first.agentId}:commitments:${runId}`,
agentId: first.agentId,
trigger: "manual",
sessionFile: resolveExtractionSessionFile(first.agentId, runId),
workspaceDir: resolveAgentWorkspaceDir(cfg, first.agentId),
config: cfg,
provider: modelRef.provider,