MCPcopy
hub / github.com/continuedev/continue / updateAgentMetadata

Function updateAgentMetadata

extensions/cli/src/util/exit.ts:104–137  ·  view source on GitHub ↗
(
  options?: ChatHistoryItem[] | UpdateAgentMetadataOptions,
)

Source from the content-addressed store, hash-verified

102 * @param options - Options including history and completion state
103 */
104export async function updateAgentMetadata(
105 options?: ChatHistoryItem[] | UpdateAgentMetadataOptions,
106): Promise<void> {
107 // Support both old signature (history array) and new signature (options object)
108 const { history, isComplete } = Array.isArray(options)
109 ? { history: options, isComplete: false }
110 : { history: options?.history, isComplete: options?.isComplete ?? false };
111
112 try {
113 const agentId = getAgentIdFromArgs();
114 if (!agentId) {
115 logger.debug("No agent ID found, skipping metadata update");
116 return;
117 }
118
119 const metadata: Record<string, any> = {};
120 const hasChanges = await collectDiffStats(metadata);
121
122 if (isComplete) {
123 metadata.isComplete = true;
124 metadata.hasChanges = hasChanges;
125 }
126
127 collectSummary(metadata, history);
128 collectSessionUsage(metadata);
129
130 if (Object.keys(metadata).length > 0) {
131 await postAgentMetadata(agentId, metadata);
132 }
133 } catch (err) {
134 // Non-critical: log but don't fail the process
135 logger.debug("Error in updateAgentMetadata (ignored)", err as any);
136 }
137}
138
139/**
140 * Display session usage breakdown in verbose mode

Callers 6

status.tsFile · 0.85
exit.tsFile · 0.85
reportFailure.tsFile · 0.85
handleExitResponseFunction · 0.85
processMessagesFunction · 0.85
serveFunction · 0.85

Calls 6

collectDiffStatsFunction · 0.85
collectSummaryFunction · 0.85
collectSessionUsageFunction · 0.85
postAgentMetadataFunction · 0.85
getAgentIdFromArgsFunction · 0.70
debugMethod · 0.45

Tested by

no test coverage detected