MCPcopy Create free account
hub / github.com/Noumena-Network/code / createAsyncAgentAttachmentsIfNeeded

Function createAsyncAgentAttachmentsIfNeeded

src/services/compact/compact.ts:1643–1674  ·  view source on GitHub ↗
(
  context: ToolUseContext,
)

Source from the content-addressed store, hash-verified

1641 * haven't been retrieved yet.
1642 */
1643export async function createAsyncAgentAttachmentsIfNeeded(
1644 context: ToolUseContext,
1645): Promise<AttachmentMessage[]> {
1646 const appState = context.getAppState()
1647 const asyncAgents = Object.values(appState.tasks).filter(
1648 (task): task is LocalAgentTaskState => task.type === 'local_agent',
1649 )
1650
1651 return asyncAgents.flatMap(agent => {
1652 if (
1653 agent.retrieved ||
1654 agent.status === 'pending' ||
1655 agent.agentId === context.agentId
1656 ) {
1657 return []
1658 }
1659 return [
1660 createAttachmentMessage({
1661 type: 'task_status',
1662 taskId: agent.agentId,
1663 taskType: 'local_agent',
1664 description: agent.description,
1665 status: agent.status,
1666 deltaSummary:
1667 agent.status === 'running'
1668 ? (agent.progress?.summary ?? null)
1669 : (agent.error ?? null),
1670 outputFilePath: getTaskOutputPath(agent.agentId),
1671 }),
1672 ]
1673 })
1674}
1675
1676/**
1677 * Scan messages for Read tool_use blocks and collect their file_path inputs

Callers 2

compactConversationFunction · 0.85

Calls 2

createAttachmentMessageFunction · 0.50
getTaskOutputPathFunction · 0.50

Tested by

no test coverage detected