agentgraphgenerator_test.go

Overview

This file contains unit tests for the agent graph generation functionality within the services package. It primarily focuses on verifying correct behavior for visualizing agents, tools, and their relationships in graph form using the gographviz library. The tests cover creation of agent and tool nodes, their captions and shapes, cluster generation for workflow agents, edge drawing between nodes, and highlighting logic for nodes and edges.

The file includes helper types and functions to mock models, agents, and tools necessary for testing. It ensures that graph construction routines accurately represent agent hierarchies, sub-agent compositions, and tool associations, as well as correctly apply visual attributes like colors, shapes, labels, and styles based on agent types and highlight states.

Helper Types and Functions

dummyLLM

newTestAgent

mockTool

Test Functions

Each test function targets a specific aspect of the graph generation code related to agents and tools visualization and graph structure.


TestNodeName


TestNodeCaption


TestNodeShape


TestShouldBuildAgentCluster


TestHighlighted


TestEdgeHighlighted


TestDrawNode


TestDrawClusterNode


TestDrawEdge


TestDrawCluster


TestBuildGraph


Important Implementation Details

Interaction with Other Parts of the System

Visual Diagram

flowchart TD
subgraph AgentGraphGeneratorTest
direction TB
dummyLLM["dummyLLM"]
newTestAgent["newTestAgent()"]
mockTool["mockTool"]
TestNodeName["TestNodeName()"]
TestNodeCaption["TestNodeCaption()"]
TestNodeShape["TestNodeShape()"]
TestShouldBuildAgentCluster["TestShouldBuildAgentCluster()"]
TestHighlighted["TestHighlighted()"]
TestEdgeHighlighted["TestEdgeHighlighted()"]
TestDrawNode["TestDrawNode()"]
TestDrawClusterNode["TestDrawClusterNode()"]
TestDrawEdge["TestDrawEdge()"]
TestDrawCluster["TestDrawCluster()"]
TestBuildGraph["TestBuildGraph()"]
dummyLLM --> newTestAgent
mockTool --> TestNodeName
newTestAgent --> TestNodeName
newTestAgent --> TestNodeCaption
newTestAgent --> TestNodeShape
newTestAgent --> TestShouldBuildAgentCluster
mockTool --> TestShouldBuildAgentCluster
TestNodeName --> TestDrawNode
TestNodeCaption --> TestDrawNode
TestNodeShape --> TestDrawNode
TestShouldBuildAgentCluster --> TestDrawClusterNode
TestHighlighted --> TestDrawNode
TestEdgeHighlighted --> TestDrawEdge
TestDrawNode --> TestDrawClusterNode
TestDrawNode --> TestDrawEdge
TestDrawClusterNode --> TestDrawCluster
TestDrawEdge --> TestDrawCluster
TestDrawCluster --> TestBuildGraph
end

This flowchart shows the dependencies and interactions among helper types and test functions in this file, illustrating the progression from basic utilities to comprehensive graph building tests.