This repository contains a minimal agent/workflow engine implemented in Python + FastAPI for the Tredence AI Engineering assignment.
The engine allows you to define:
- A set of nodes (execution steps)
- A shared state dictionary that flows through the nodes
- Edges between nodes (sequential or conditional)
- A simple looping mechanism
- A tool registry to plug in Python functions
It includes a working sample workflow (Option B):
Long text → split into chunks → generate chunk summaries → merge → refine summary in a loop.
tredence_assignment/
├── app/
│ └── main.py
├── README.md
└── requirements.txt
pip install -r requirements.txt
uvicorn app.main:app --reload
Open Swagger UI:
http://127.0.0.1:8000/docs
A node represents a step in the workflow:
- id
- tool
- next
- branch condition
- conditional paths
A shared Python dictionary passed & updated through every node.
Registered using:
@register_tool("split_text")
def split_text_tool(state):
...Boolean functions for branching or looping.
Defined using LoopConfig:
- node_id
- condition
- max_iterations
Creates a workflow graph.
Runs a graph with initial state.
Returns the log and current state of a workflow run.
- Splits text into chunks
- Creates summaries
- Merges summaries
- Refines summary
- Loops until summary meets limit
- Database persistence
- WebSocket log streaming
- Parallel node execution
- Background task support
- Graph visualization UI
This project satisfies all required components:
- Minimal workflow engine
- State-driven execution
- Branching & looping
- Tool registry
- FastAPI backend
- Complete sample workflow