Description
DAGent offers an opinionated Python library for the swift creation of AI agents with minimal overhead. The core concept revolves around structuring AI agent logic into a workflow, visualized as a Directed Acyclic Graph (DAG). Each Python function within the agent is treated as a node in this graph.
Agentic behavior is achieved by employing Large Language Models (LLMs) to infer which function to execute next. This inference process is managed by a "Decision Node," which acts as the central point for LLM-driven decision-making. Tools, which are essentially Python functions, can be integrated into the agent. It is highly recommended to provide clear docstrings and type annotations for these functions to assist the LLM in understanding their purpose and parameters, especially for more complex tools.
The library distinguishes between `FunctionNode` and `DecisionNode`. A `FunctionNode` executes a Python function, and when attached to a `DecisionNode`, it can be treated as a tool that an LLM can select. The `DecisionNode` is where the LLM chooses from a set of available functions. The `.compile()` method automatically generates and saves tool descriptions in JSON format under a `Tool_JSON` folder, which can be manually edited if the agent's reliability needs improvement. The `prev_output` parameter is crucial for passing data between functions in the workflow, requiring it to be present in the function signature. For handling unexpected parameters, adding `**kwargs` to function signatures is advised.
DAGent supports the use of various LLM models for inference and tool description generation. Users can specify the desired model when calling LLM functions or when compiling `DecisionNode` instances, allowing flexibility in choosing models like those from Groq or Ollama. The library facilitates dynamic parameter overriding for function nodes, enabling fine-tuning of agent behavior during execution. Feedback on the library can be provided through a dedicated form.
DAGent's Core Features
Build AI agents using existing Python code
Structure agent logic as Directed Acyclic Graphs (DAGs)
LLM-driven function selection via Decision Nodes
Functions treated as tools for LLMs
Automatic generation of tool descriptions (JSON)
Support for multiple LLM models (e.g., Groq, Ollama)
Pass data between functions using `prev_output` parameter
Dynamic parameter overriding for function nodes
Includes example quickstart agent
Getting Started with DAGent
Install: pip install dagent or rye add dagent
Configure: Ensure your API key (e.g., OPENAI_API_KEY) is available
Develop: Define Python functions to act as nodes
Integrate: Use DecisionNode to allow LLMs to select functions
Compile: Run `.compile()` to generate tool descriptions
Execute: Run your agent workflow
DAGent's Use Cases
- Automated Task Execution
- Data Analysis Agents
- Code Generation Assistants
- Workflow Automation
- Custom AI Tool Integration
- LLM-powered Scripting








