MCPcopy Create free account
hub / github.com/Roy3838/Observer / fetchAgentReferenceData

Function fetchAgentReferenceData

app/src/utils/agentParser.ts:246–285  ·  view source on GitHub ↗
(
  references: AgentReference[]
)

Source from the content-addressed store, hash-verified

244 * @returns Array of complete agent reference data
245 */
246export async function fetchAgentReferenceData(
247 references: AgentReference[]
248): Promise<AgentReferenceData[]> {
249 const results: AgentReferenceData[] = [];
250
251 for (const reference of references) {
252 try {
253 // Fetch agent config and code from agent_database
254 const agent = await getAgent(reference.agentId);
255 const code = agent ? await getAgentCode(reference.agentId) : null;
256 const memory = agent ? await getAgentMemory(reference.agentId) : '';
257
258 // Fetch recent runs from IterationStore
259 let recentRuns: IterationData[] = [];
260 if (reference.runCount > 0) {
261 recentRuns = await getRecentAgentRuns(reference.agentId, reference.runCount);
262 }
263
264 results.push({
265 reference,
266 agent,
267 code,
268 memory,
269 recentRuns
270 });
271 } catch (error) {
272 console.error(`Failed to fetch data for agent ${reference.agentId}:`, error);
273 // Add placeholder entry for failed fetch
274 results.push({
275 reference,
276 agent: null,
277 code: null,
278 memory: '',
279 recentRuns: []
280 });
281 }
282 }
283
284 return results;
285}
286
287/**
288 * Extract unique agent references from all messages in conversation

Callers

nothing calls this directly

Calls 6

getAgentFunction · 0.90
getAgentCodeFunction · 0.90
getAgentMemoryFunction · 0.90
getRecentAgentRunsFunction · 0.85
pushMethod · 0.80
errorMethod · 0.80

Tested by

no test coverage detected