- The paper introduces TaskGen, a framework that decomposes complex tasks into manageable subtasks using Equipped Functions and Inner Agents.
- It presents a novel methodology by integrating StrictJSON for concise LLM outputs and employing memory management through Shared Memory and a Memory Bank.
- The paper demonstrates practical success with high performance in dynamic maze navigation, TextWorld puzzles, and web browsing tasks.
TaskGen: A Task-Based, Memory-Infused Agentic Framework using StrictJSON
Overview
TaskGen is an open-source agentic framework designed to solve complex tasks by decomposing them into manageable subtasks. Each subtask is mapped to either an Equipped Function or another Agent. The framework employs StrictJSON to ensure concise JSON-based output from LLMs, reducing verbosity and token usage. This approach facilitates efficient execution across various agentic tasks while managing memory on a need-to-know basis, allowing agents to react dynamically to evolving environments.
Figure 1: An Overview of TaskGen.
Framework Architecture
Task Breakdown with Equipped Functions and Inner Agents
TaskGen operates by breaking a task into subtasks, each executed via Equipped Functions or Inner Agents. Equipped Functions limit the action space, making task execution tractable (Figure 2). For complex tasks, the hierarchical model allows a Meta Agent to delegate subtasks to Inner Agents, enhancing processing capabilities (Figure 3).
Figure 2: Constraining action space by Equipped Functions.
Figure 3: Inner Agents assigned as Equipped Functions to a Meta Agent helps increase processing capability.
Memory Management
Shared Memory is pivotal in TaskGen, allowing components to share crucial information only when necessary. There are two types of Shared Memory: Subtasks Completed and Shared Variables (Figure 4). TaskGen also employs a Memory Bank, storing abstracted memories used for Retrieval Augmented Generation (RAG) based on semantic similarity to tasks.
Figure 4: Two types of Shared Memory: Subtasks Completed and Shared Variables.
StrictJSON Output
StrictJSON is utilized over traditional JSON Schema for its minimal verbosity and efficiency, crucial for reducing token usage in LLM communication. It supports type checking and iterative error correction leading to superior performance (Figure 5).
Figure 5: More concise output using JSON as compared to Free Text using gpt-3.5-turbo on 12 Jul 2024.
Implementation Steps
To implement TaskGen, follow these steps:
- Install Package: Run
pip install taskgen-ai.
- Define LLM: Use the format
def LLM(user_prompt: str, system_prompt: str) -> str.
- Define Agent: Create an Agent using
agent = Agent(name, description, LLM = LLM).
- Equip Functions: Assign Equipped Functions to the Agent with
agent.assign_functions([fn_1, fn_2]).
- Execute Tasks: Run tasks using
agent.run(task).
- Query Agent: Retrieve information with
agent.reply_user(query).
Evaluation and Results
TaskGen has been tested in diverse environments showcasing adaptability:
- Dynamic Maze Navigation: 100% success rate in navigating 40x40 mazes with dynamic obstacles.
- TextWorld Escape Room: Achieved a 96% solve rate where dense rewards and goals were specified.
- Web Browsing: Successfully completed 69% of actions across various web tasks.
- MATH Dataset: Averaged 71% accuracy over Level-5 problems.
- RAG-based QA: Outperformed baseline LLM with an F1 score of 47.03%, precision of 40.75%, and recall of 55.59%.
Conclusion
TaskGen represents a significant advancement in agentic frameworks by integrating efficient task decomposition, strict JSON processing, and strategic memory use. Its practical applications extend to complex problem-solving environments such as dynamic navigation, interactive fiction, web browsing, and mathematical computation. Future developments will focus on enhancing memory management, integrating multi-modal support, and fostering collaborative agent systems. TaskGen is actively developed, with community contributions encouraged for continual improvement and expansion.