( references: AgentReference[] )
| 264 | * @returns Array of complete agent reference data |
| 265 | */ |
| 266 | export async function fetchAgentReferenceData( |
| 267 | references: AgentReference[] |
| 268 | ): Promise<AgentReferenceData[]> { |
| 269 | const results: AgentReferenceData[] = []; |
| 270 | |
| 271 | for (const reference of references) { |
| 272 | try { |
| 273 | // Fetch agent config and code from agent_database |
| 274 | const agent = await getAgent(reference.agentId); |
| 275 | const code = agent ? await getAgentCode(reference.agentId) : null; |
| 276 | const memory = agent ? await getAgentMemory(reference.agentId) : ''; |
| 277 | |
| 278 | // Fetch recent runs from IterationStore |
| 279 | let recentRuns: IterationData[] = []; |
| 280 | if (reference.runCount > 0) { |
| 281 | recentRuns = await getRecentAgentRuns(reference.agentId, reference.runCount); |
| 282 | } |
| 283 | |
| 284 | results.push({ |
| 285 | reference, |
| 286 | agent, |
| 287 | code, |
| 288 | memory, |
| 289 | recentRuns |
| 290 | }); |
| 291 | } catch (error) { |
| 292 | console.error(`Failed to fetch data for agent ${reference.agentId}:`, error); |
| 293 | // Add placeholder entry for failed fetch |
| 294 | results.push({ |
| 295 | reference, |
| 296 | agent: null, |
| 297 | code: null, |
| 298 | memory: '', |
| 299 | recentRuns: [] |
| 300 | }); |
| 301 | } |
| 302 | } |
| 303 | |
| 304 | return results; |
| 305 | } |
| 306 | |
| 307 | /** |
| 308 | * Extract unique agent references from all messages in conversation |
no test coverage detected