Sefism is free for learners. We are here to help you grow, one step at a time.Join for free
Sefism.
AI & ML

Multi-Step Agent Workflow Runner with Cost Tracking

A workflow runner for developers building multi-step language model features, executing each workflow as an explicit graph with retries, per-step cost and latency tracking and a trace view of exactly what happened. An advanced AI final year project that builds the observability most agent frameworks leave out, and measures when decomposition pays off.

Difficulty

Advanced

Needs a team, real planning, and a supervisor who knows the area.
Effort

2 semesters · 2 to 3 students

Deliverables

7 to ship

4 optional extras

Suggested stack

PythonFastAPIPostgreSQLRedis for the job queueReactAn LLM API plus one local model
A suggestion, not a requirement. Swap anything for what you already know.

What you should ship

  • A workflow definition format (YAML or Python) describing steps, dependencies, model calls and tool calls as a directed acyclic graph
  • An execution engine with per-step retry, timeout and failure handling, and parallel execution of independent branches
  • Durable state so a run survives a worker crash and resumes from the last completed step without repeating paid calls
  • Trace persistence recording every prompt, response, token count, cost and duration, with large payloads stored separately from the index
  • A trace viewer showing a run as a timeline with per-step cost and the ability to inspect any step
  • Two worked workflows (for example document triage and report drafting) compared against a single-prompt baseline on accuracy, cost and latency
  • A load test showing trace storage and query performance after at least 10,000 runs

If you have time left

  • Replay a recorded run with one step's prompt modified, to test a change against real inputs
  • Caching of deterministic steps across runs
  • Export traces in OpenTelemetry format so existing observability tools can read them
  • Per-workflow budgets that stop a run before it exceeds a cost limit

The problem with chained model calls

Chaining several language model calls is easy to start and very hard to debug. A support-ticket triage flow might classify, retrieve, draft, check tone and summarise. When the final answer is wrong, the question is which of five steps went wrong, and a lot of tooling cannot answer it cleanly. Cost is similarly invisible until the monthly bill arrives, and a crashed worker can re-run steps that were already paid for.

Teams at startups and software houses building these features need two things: a runtime they can reason about, and a record of every step.

What already exists and the gap

  • LangGraph models agent workflows as graphs, with checkpointing, and LangSmith provides tracing for them.
  • Langfuse is an open-source tracing and observability platform for model applications.
  • Temporal provides durable execution for long-running workflows in general, and is increasingly used for AI pipelines.
  • n8n offers visual workflows with model steps for lower-code users.

The pieces exist, but usually in separate products: one for execution, another for tracing, another for cost. The gap this project fills is a small, readable runner where execution, durable state, tracing and cost attribution are one design, plus a measured answer to a question teams keep guessing about: when is a decomposed workflow worth its extra cost over one good prompt?

What you build

  • Definition format: steps, inputs, outputs, dependencies and retry policy.
  • Engine: a scheduler that runs ready steps, respects dependencies, retries failures and records state after each step.
  • Workers: pull jobs from a queue, call models and tools, report results.
  • Trace store and viewer: timeline, per-step cost, full prompt and response on click.
  • Experiments: the same task as one prompt and as a workflow.

Why explicit beats autonomous here

An agent that decides its own steps is harder to debug, more expensive and less predictable. A defined graph with model calls at the nodes covers a large share of real business use cases and can actually be reasoned about. Make that argument in your report and back it with numbers.

The technically interesting part

Two hard problems.

Exactly-once effects on an at-least-once system. Workers crash, retries happen. A step that already succeeded must not be paid for or executed again on resume. Record step completion transactionally with its output, and make tool calls idempotent with step-level keys, the pattern durable execution systems like Temporal are built around.

Trace storage. Prompts and responses are large, runs are frequent, and a naive schema becomes unusable quickly. Keep a compact index (run, step, status, tokens, cost, timing) separate from payload storage, and measure query speed at scale.

How to evaluate it

  • Decomposition study: for both workflows, accuracy on a labelled set of at least 50 inputs, cost per run and p95 latency, workflow versus single prompt. A concrete result such as "decomposition was more accurate at three times the cost" is exactly what your report should lead with.
  • Crash test: kill workers mid-run 20 times; count repeated paid calls (target zero) and runs that finish correctly.
  • Overhead: engine latency added per step.
  • Trace performance: viewer load time and query time after 10,000 runs.
  • Developer test: give three developers a broken workflow and time how long they take to find the failing step with your viewer.

Suggested plan

  1. Weeks 1 to 4: definition format, simple sequential engine, trace schema.
  2. Weeks 5 to 9: dependencies, parallel branches, retries, timeouts.
  3. Weeks 10 to 14: durable state and crash recovery, measured.
  4. Semester 2, weeks 1 to 5: trace viewer, cost attribution, storage at scale.
  5. Weeks 6 to 10: the two workflows and the decomposition study.
  6. Weeks 11 to 14: developer test, report and release.

Path to a product

The realistic path is open source first. A small, well-documented runner with good traces attracts developers who find larger frameworks heavy; publishing the decomposition study brings attention. Monetise later with a hosted trace store and team features, or use it as a portfolio centrepiece for AI platform and backend infrastructure roles, where this exact set of problems (queues, retries, idempotency, observability) is daily work.

Scope warning

  • Do not write another framework abstraction layer with dozens of integrations.
  • Do not build autonomous tool-choosing agents; explicit graphs only.
  • Do not build user accounts, teams or billing.
  • Execution, durability, tracing and cost accounting is already a full project.

Learn what you need on Sefism

Get help with this idea

The risk is spending the year on framework features instead of durability, tracing and the decomposition study. Tauseef can help you draw the line, design the crash tests and plan an experiment whose result is worth publishing. If you are new here, create a free account first.

Ideas and guidance, not finished projects

These are project ideas and scoping guidance, published free for students to use as a starting point. I do not build, write, or sell final-year projects, and I do not complete coursework for anyone. Take an idea, make it yours, and build it.

Not sure this one fits you?

I help students pick an idea that matches their skills and their deadline, then scope it down until it is finishable. Guidance only, never done for you.

Discuss this idea
Work with me

Stuck on something specific?

Writing only gets you so far. If you want an answer to your situation rather than the general case, book a session and we will work through it together. Sessions are free for approved Sefism members, and a few slots open each week.