fix(core): preserve per-task tokenUsage across archival
taskToArchiveEntry() builds the archived record from an explicit field whitelist that omits task.tokenUsage, and ArchivedTaskEntry has no tokenUsage field — so a task's input/output/cache token (and derived cost) accounting is silently dropped the moment it is swept out of the live tasks table into archive.db. Every archived task loses its token stats. Add tokenUsage to the ArchivedTaskEntry type and thread it through both the archive write path (taskToArchiveEntry) and the two restore paths (archiveEntryToTask, unarchiveTask) so the counts round-trip intact.
This commit is contained in:
@@ -2328,6 +2328,7 @@ export class TaskStore extends EventEmitter<TaskStoreEvents> {
|
||||
validatorModelId: entry.validatorModelId,
|
||||
planningModelProvider: entry.planningModelProvider,
|
||||
planningModelId: entry.planningModelId,
|
||||
tokenUsage: entry.tokenUsage,
|
||||
breakIntoSubtasks: entry.breakIntoSubtasks,
|
||||
noCommitsExpected: entry.noCommitsExpected,
|
||||
branchContext: entry.branchContext,
|
||||
@@ -2467,6 +2468,7 @@ export class TaskStore extends EventEmitter<TaskStoreEvents> {
|
||||
validatorModelId: task.validatorModelId,
|
||||
planningModelProvider: task.planningModelProvider,
|
||||
planningModelId: task.planningModelId,
|
||||
tokenUsage: task.tokenUsage,
|
||||
breakIntoSubtasks: task.breakIntoSubtasks,
|
||||
noCommitsExpected: task.noCommitsExpected,
|
||||
baseBranch: task.baseBranch,
|
||||
@@ -14910,6 +14912,7 @@ ${TASK_UPSERT_SQL_ASSIGNMENTS}
|
||||
validatorModelId: entry.validatorModelId,
|
||||
planningModelProvider: entry.planningModelProvider,
|
||||
planningModelId: entry.planningModelId,
|
||||
tokenUsage: entry.tokenUsage,
|
||||
breakIntoSubtasks: entry.breakIntoSubtasks,
|
||||
noCommitsExpected: entry.noCommitsExpected,
|
||||
modifiedFiles: entry.modifiedFiles,
|
||||
|
||||
@@ -4920,6 +4920,8 @@ export interface ArchivedTaskEntry {
|
||||
/** Optional: planning model override for triage agent */
|
||||
planningModelProvider?: string;
|
||||
planningModelId?: string;
|
||||
/** Per-task token/cost accounting (input/output/cache) preserved across archival. */
|
||||
tokenUsage?: TaskTokenUsage;
|
||||
/** Optional: other metadata to preserve */
|
||||
breakIntoSubtasks?: boolean;
|
||||
noCommitsExpected?: boolean;
|
||||
|
||||
Reference in New Issue
Block a user