Back to selected work

PROJECT 03 / Agentic AI & workflow automation

Maintenance Triage Agent.

Intelligent automation with human control.

A stateful AI workflow combining multi-format document processing, LLM-driven tool selection, deterministic approval policies and persistent human review.

THE COMPILED LANGGRAPH

The actual compiled LangGraph graph: format routing, a critic, a human-review loop and tool calling.

Compiled LangGraph: start, classify_input, branches to email_agent, json_agent, pdf_agent and unsupported, all converging on critic, which routes to human_review or tool_calling, then end. Human review loops back to the critic.

Original, unmodified screenshot · Esc to close · Open full size

ONE LANGFUSE TRACE, TWO INVOCATIONS

One trace containing two graph invocations: the initial run that paused for review and the resumed run that finished with tool calling. Critic confidence is “high”, yet review was still required by the cost rule.

Langfuse trace for multi-format-ai-system: a first LangGraph invocation with classify_input, pdf_agent, critic and human_review, and a second invocation with human_review, route-after-human-review and tool_calling, inside one trace. Confidence is high and the extracted invoice total is 12500.

Original, unmodified screenshot · Esc to close · Open full size

The actual LangGraph graph and a real Langfuse trace of a $12,500 invoice that paused for review and then resumed. Click either image to enlarge.ORIGINAL CAPTURES
3input formats: email, JSON, PDF
18passing tests, incl. 4 legacy³
HITLpersistent human review

³ The count includes four legacy router tests. External CRM and risk-alert actions are simulated; this is not a commercial deployment and no decision-accuracy claim is made.

01 / OVERVIEW

Automation needs a place to pause.

The Maintenance Triage Agent is an engineering prototype adapted from a rule-based document classifier (originally called Multi-Format AI System). It accepts email, JSON and PDF inputs, rejects unsupported formats, extracts fields per format, and runs them through a LangGraph StateGraph.

A Groq-backed critic assesses intent and confidence. The workflow then either selects a tool or pauses for a person. Downstream actions, post_to_crm and post_risk_alert, are simulated: there is no real vendor dispatch, notification or CRM.

The actual compiled LangGraph graph: format routing, a critic, a human-review loop and tool calling.

Compiled LangGraph: start, classify_input, branches to email_agent, json_agent, pdf_agent and unsupported, all converging on critic, which routes to human_review or tool_calling, then end. Human review loops back to the critic.

Original, unmodified screenshot · Esc to close · Open full size

The actual compiled LangGraph graph: format routing, a critic, a human-review loop and tool calling.LANGGRAPH GRAPH · CLICK TO EXPAND

02 / THE PROBLEM

Not every model decision should become an action.

Real inputs arrive in different shapes, and a confident model can still be wrong about money. The question was how to let a model do the interpretation while keeping approval rules explicit and keeping a paused decision alive until a human answers it, even across a connection boundary.

FastAPI serves a Jinja-rendered interface at GET /ui. The captures below use Swagger UI to show the requests and responses for processing a file and reviewing a thread.

03 / ARCHITECTURE

Classify. Review. Act.

Input is classified as email, JSON, PDF or unsupported, and handled by a format-specific agent. All paths converge at a critic that assesses intent and confidence. A deterministic cost gate or low confidence sends the item to human review, which is checkpointed in PostgreSQL by thread ID. Approval resumes toward tool selection. Rejection returns to the critic with feedback. Tool calling runs a simulated CRM post or risk alert.

EXPLANATORY ILLUSTRATION · NOT A LIVE UI Endpoints: POST /process, GET /review/{thread_id}, POST /review/{thread_id}.

Every execution is traced in Langfuse. One request that pauses and later resumes appears as two graph invocations inside a single trace.

One trace containing two graph invocations: the initial run that paused for review and the resumed run that finished with tool calling. Critic confidence is “high”, yet review was still required by the cost rule.

Langfuse trace for multi-format-ai-system: a first LangGraph invocation with classify_input, pdf_agent, critic and human_review, and a second invocation with human_review, route-after-human-review and tool_calling, inside one trace. Confidence is high and the extracted invoice total is 12500.

Original, unmodified screenshot · Esc to close · Open full size

One trace containing two graph invocations: the initial run that paused for review and the resumed run that finished with tool calling. Critic confidence is “high”, yet review was still required by the cost rule.LANGFUSE TRACE · CLICK TO EXPAND

04 / DECISIONS & TRADE-OFFS

Intelligence with explicit controls.

A deterministic cost gate, separate from model confidence.

An invoice whose extracted amount is strictly greater than $10,000, or any low-confidence result, goes to review. High confidence alone cannot bypass a successfully extracted cost.

Trade-off. A rule is only as good as its input: if the amount is not extracted, the gate cannot fire.

Persist the pause.

Human review is a stateful boundary checkpointed with PostgreSQL AsyncPostgresSaver, keyed by thread ID, not a transient confirmation in a browser.

Trade-off. Persistence adds a database dependency and a review queue that someone must watch.

Reject means “think again”, not “stop”.

Rejection returns the item to the critic with the reviewer's feedback so intent can be revised.

Trade-off. There is currently no terminal rejection state, so a rejected thread can remain pending.

Simulate downstream effects.

Tool calls record what would happen without contacting any external system.

Trade-off. It keeps the prototype safe, but proves nothing about a real integration.

05 / DEBUGGING

Inspect the path, not only the output.

An action branch that could never fire. Live testing found an action branch that was unreachable. The JSON capture below now completes with a simulated risk alert when a complaint note mentions compliance and fraud.

Completed threads had to be reviewable. Retrieving a review for a thread that had already finished needed handling, as did correlating the initial and resumed runs of one thread in a single trace.

A JSON complaint whose note mentions compliance and fraud completes with a simulated risk-alert action, even though the initial classification was Complaint.

FastAPI docs: POST /process with sample.json returns status completed, classification JSON with intent Complaint, a note mentioning a possible GDPR compliance issue and fraud flag, and action post_risk_alert.

Original, unmodified screenshot · Esc to close · Open full size

A JSON complaint whose note mentions compliance and fraud completes with a simulated risk-alert action, even though the initial classification was Complaint.POST /process · CROPPED VIEW, CLICK FOR FULL IMAGE

06 / TESTING & EVALUATION

A bounded test result.

18 tests pass, including 4 legacy router tests, with one PyPDF2 deprecation warning. They include a test that an interrupt survives a genuinely fresh database connection.

The review lifecycle below was demonstrated with real calls. A $12,500 invoice stops at pending_review; the same thread is retrieved and approved; a separate thread is rejected with feedback.

  1. 01

    Cost gate

    $12,500 exceeds the $10,000 threshold, so the invoice pauses as cost_threshold_exceeded.

  2. 02

    Same thread retrieved

    GET /review returns the same pending state by thread ID.

  3. 03

    Approved

    POST approved: true resumes the workflow and completes with a simulated risk alert.

  4. 04

    Rejected

    A separate thread revises intent to “request revised quote” and stays pending.

A $12,500 invoice PDF stops at pending_review because it exceeds the $10,000 threshold.

FastAPI docs: POST /process with invoice_12500.pdf returns status pending_review, reason cost_threshold_exceeded, and the detail “Estimated cost $12,500.00 exceeds the $10,000 auto-approval threshold.”

Original, unmodified screenshot · Esc to close · Open full size

A $12,500 invoice PDF stops at pending_review because it exceeds the $10,000 threshold.COST GATE · CROPPED VIEW, CLICK FOR FULL IMAGE

The same thread ID retrieved later still returns the pending review. This capture shows same-thread retrieval, not a process restart.

FastAPI docs: GET /review/{thread_id} with the same thread ID returns the pending_review state for the invoice.

Original, unmodified screenshot · Esc to close · Open full size

The same thread ID retrieved later still returns the pending review. This capture shows same-thread retrieval, not a process restart.GET /review · CROPPED VIEW, CLICK FOR FULL IMAGE

Approving the pending thread resumes the workflow; it completes with a simulated risk-alert action.

FastAPI docs: POST /review/{thread_id} with approved true returns status completed and action post_risk_alert for the $12,500 invoice.

Original, unmodified screenshot · Esc to close · Open full size

Approving the pending thread resumes the workflow; it completes with a simulated risk-alert action.APPROVE · CROPPED VIEW, CLICK FOR FULL IMAGE

A separate thread rejected with feedback: the critic revises the intent to “request revised quote”, but the thread remains pending. There is no terminal rejection state yet.

FastAPI docs: POST /review/{thread_id} with approved false and the feedback “Cost seems inflated for an HVAC compressor swap - request a revised quote from the vendor.” The response is pending_review with intent “request revised quote”.

Original, unmodified screenshot · Esc to close · Open full size

A separate thread rejected with feedback: the critic revises the intent to “request revised quote”, but the thread remains pending. There is no terminal rejection state yet.REJECT · CROPPED VIEW, CLICK FOR FULL IMAGE

A captured CI run: 18 passed, 1 warning in 1.36s, including 4 legacy router tests and a fresh-connection persistence test. The warning is a PyPDF2 deprecation.

GitHub Actions log of pytest: 18 items collected, 18 passed with 1 warning in 1.36 seconds, including four legacy router tests and a test that an interrupt survives a genuinely fresh connection.

Original, unmodified screenshot · Esc to close · Open full size

A captured CI run: 18 passed, 1 warning in 1.36s, including 4 legacy router tests and a fresh-connection persistence test. The warning is a PyPDF2 deprecation.CI RUN · CROPPED VIEW, CLICK FOR FULL IMAGE

WHAT THIS DOES NOT SHOW

Restart recovery is documented historically; the captures show same-thread retrieval, not a process restart. There is no decision-accuracy evaluation, cost-saving claim or real integration.

The FastAPI Swagger UI lists the processing and review endpoints, alongside GET /ui, which serves the Jinja-rendered interface.

FastAPI OpenAPI page listing GET /, POST /process, POST and GET /review/{thread_id}, GET /logs and GET /ui, with Body_process_process_post, ReviewDecision and validation schemas.

Original, unmodified screenshot · Esc to close · Open full size

The FastAPI Swagger UI lists the processing and review endpoints, alongside GET /ui, which serves the Jinja-rendered interface.OPENAPI · CLICK TO EXPAND

07 / DEPLOYMENT

Source available. No public deployment.

The repository is available for technical review and its stack includes Docker. No public deployment or live demo is presented, and none should be inferred.

08 / LIMITATIONS

A workflow project, not a dispatch service.

  • Cost-gate reliability depends on amount extraction. A narrow invoice regex or a missing amount may let an item bypass the gate, and costs inside nested JSON are not normalised.
  • External CRM and risk-alert actions are simulated.
  • There is no reviewer authentication, and domain adaptation for maintenance is incomplete.
  • A rejection loop can leave a thread pending indefinitely, and strict model-output validation is still needed.
  • There is no broad decision-quality evaluation, and PyPDF2 is deprecated.

09 / NEXT STEPS

What I would do next.

  • More robust amount extraction, with a fail-safe that sends missing amounts to review.
  • An explicit terminal rejection state, and authentication for reviewers.
  • Real integrations behind the simulated tools, and a broader evaluation of routing decisions.

These are planned improvements, not completed work.

Read the source and documentation on GitHub

WORK WITH ME

Need something like this built?

I take on focused tasks as well as larger implementations. Tell me what you are trying to build.

Let's build something
that works.

HIRING AN ENGINEER?Discuss a role

Open to full-time engineering roles. Relocation across India is fine.

View résumé
HAVE A PROJECT?Discuss a project

Focused tasks or full builds. Tell me what you are trying to ship.

See what I can build

Draft an email

What is this about?

This opens a draft in your email app. Nothing is sent or stored from this page.