Skip to content

premsingh1507/TREDENCE_ASSIGNMENT

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Minimal Workflow Engine – Tredence AI Engineering Assignment

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.


Project Structure

tredence_assignment/
├── app/
│   └── main.py
├── README.md
└── requirements.txt

Getting Started

Install dependencies

pip install -r requirements.txt

Run the FastAPI app

uvicorn app.main:app --reload

Open Swagger UI:

http://127.0.0.1:8000/docs

Core Concepts

Node

A node represents a step in the workflow:

  • id
  • tool
  • next
  • branch condition
  • conditional paths

State

A shared Python dictionary passed & updated through every node.

Tools

Registered using:

@register_tool("split_text")
def split_text_tool(state):
    ...

Conditions

Boolean functions for branching or looping.

Looping

Defined using LoopConfig:

  • node_id
  • condition
  • max_iterations

Endpoints

POST /graph/create

Creates a workflow graph.

POST /graph/run

Runs a graph with initial state.

GET /graph/state/{run_id}

Returns the log and current state of a workflow run.


Sample Workflow (Option B – Summarization)

  1. Splits text into chunks
  2. Creates summaries
  3. Merges summaries
  4. Refines summary
  5. Loops until summary meets limit

Future Improvements

  • Database persistence
  • WebSocket log streaming
  • Parallel node execution
  • Background task support
  • Graph visualization UI

Summary

This project satisfies all required components:

  • Minimal workflow engine
  • State-driven execution
  • Branching & looping
  • Tool registry
  • FastAPI backend
  • Complete sample workflow

About

Minimal Workflow Engine built with Python and FastAPI to execute state-driven task pipelines with support for branching and looping. Implements a tool-based node system along with REST APIs to create, run, and track workflows. Includes a working summarization workflow demonstrating full end-to-end execution.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages