Inspiration

TingHao was inspired by a real bakery inventory problem.

During discussions with the bakery stakeholder, we learned that stock information was often incomplete. For example, when 10 kg of an ingredient arrived, staff might move only 2 kg into the production area and keep the remaining 8 kg in storage without informing the owner. Damaged items, shortages, and supplier returns were also difficult to track consistently.

This created several operational risks:

  • Ingredients could run out without warning.
  • Staff might overbuy items that were already available in storage.
  • Expiring ingredients could become waste.
  • Purchase orders and supplier communication were handled manually.
  • The owner had limited visibility into receiving discrepancies and stock allocation.

We wanted to build more than another inventory dashboard. Our goal was to create an agent that could observe inventory signals, predict stock risk, recommend procurement actions, execute business tools, wait for human approval, and record the complete outcome.

TingHao is submitted under Track 4: Autopilot Agent.

What it does

TingHao is a Qwen-powered inventory and procurement autopilot for bakeries and small food businesses.

It connects inventory monitoring, stock prediction, supplier comparison, purchase-order creation, supplier communication, goods receiving, and audit records into one end-to-end workflow.

The main workflow is:

  1. Observe current inventory, stock movements, expiry dates, pending purchase orders, and supplier lead times.
  2. Predict whether an ingredient should be purchased now, monitored, purchased in a smaller quantity, or used before expiry.
  3. Use Qwen Cloud to interpret ambiguous procurement information and generate business-friendly reasoning.
  4. Check for duplicate purchase orders and other safety conditions.
  5. Compare eligible suppliers using existing supplier records.
  6. Create a purchase-order draft with a suggested quantity, unit price, and expected delivery date.
  7. Pause at a human approval checkpoint.
  8. Generate a supplier email draft after approval.
  9. Send the approved message through Resend to a controlled real test inbox.
  10. Record supplier confirmation, receiving discrepancies, damaged quantities, returns, shortages, and stock allocation.
  11. Store the complete mission in the Agent Audit Visualizer.

TingHao does not expose raw model chain-of-thought. Instead, it records safe and auditable decision summaries such as:

  • trigger;
  • observation;
  • selected tool;
  • tool result;
  • decision;
  • confidence;
  • approval status;
  • external action;
  • verified outcome.

How we built it

TingHao uses a single-agent tool-use architecture.

Qwen Cloud acts as the reasoning and language layer, while Laravel remains responsible for deterministic business rules, database operations, authorization, and safety checks.

The main technology stack includes:

  • Laravel for the full-stack application, workflow orchestration, permissions, purchase orders, receiving, and audit records.
  • Qwen Cloud, using qwen-plus, for procurement interpretation, business reasoning, supplier email generation, and bounded action selection.
  • FastAPI for stock-action prediction using summarized inventory, usage, expiry, pending-order, calendar, and supplier lead-time signals.
  • Supabase PostgreSQL for persistent inventory and agent workflow data.
  • Resend for approved external supplier email delivery in controlled test mode.
  • Docker and Docker Compose for application deployment.
  • Nginx as the public reverse proxy.
  • Alibaba Cloud ECS as the production deployment environment.
  • Laravel Scheduler and cron for proactive inventory scanning.

The deployed architecture is:

Browser
→ Nginx on Alibaba Cloud ECS
→ Laravel TingHao Agent
→ Private FastAPI prediction service
→ Supabase database, Qwen Cloud API, and Resend API

The FastAPI prediction service remains private inside the Docker network. Qwen API keys, Resend keys, and database credentials are stored only as server-side environment variables.

Challenges we ran into

One of the biggest challenges was proving that TingHao was an actual agent workflow instead of a collection of fixed if/else screens.

We solved this by implementing a bounded decision loop where Qwen proposes an action, Laravel validates the proposed action against the current workflow state, executes an approved business tool, observes the result, and continues until it reaches a valid terminal state or human checkpoint.

We also discovered that an AI model could attempt to stop a mission too early. In one test, Qwen selected stop before the open-purchase-order check had been completed. We added a production guardrail that rejects premature stop actions and safely continues with the required tool.

Other challenges included:

  • Windows PHP SSL certificate errors when connecting to Qwen Cloud.
  • Making automated tests deterministic without consuming live Qwen tokens.
  • Preventing duplicate purchase orders during scheduled scans.
  • Separating stock prediction facts from Qwen-generated explanations.
  • Supporting damaged, returned, shortage, and partially allocated stock during receiving.
  • Sending a real external email safely while using Resend test mode.
  • Deploying Laravel and FastAPI together on Alibaba Cloud ECS.
  • Keeping the interface understandable for business users while preserving technical audit evidence for judges.

Accomplishments that we're proud of

We are proud that TingHao now demonstrates a complete procurement workflow instead of stopping at an AI recommendation.

The system can:

  • detect low-stock and expiry risks;
  • generate stock-action predictions;
  • use live Qwen Cloud reasoning with mock mode disabled;
  • compare supplier records;
  • create purchase-order drafts;
  • require administrator approval;
  • generate supplier email drafts;
  • send a real email through Resend to a controlled Outlook inbox;
  • record supplier confirmation;
  • process accepted, damaged, returned, and shortage quantities;
  • allocate stock between storage and production areas;
  • prevent duplicate purchase orders;
  • run scheduled autopilot scans;
  • maintain a detailed, judge-friendly agent audit trail;
  • run publicly on Alibaba Cloud ECS.

We are especially proud that the system preserves human control. TingHao may prepare recommendations and drafts, but it cannot approve purchase orders, send supplier communication, or modify critical stock records without the required authorization.

What we learned

We learned that a production-ready agent needs more than an LLM prompt.

A reliable business agent requires:

  • a reasoning model;
  • deterministic tools;
  • structured workflow state;
  • validation before execution;
  • human approval for high-impact actions;
  • idempotency and duplicate prevention;
  • failure handling;
  • audit records;
  • measurable business outcomes.

We also learned that prediction and reasoning should remain separate.

The FastAPI service produces stock facts and recommended actions. Qwen then explains those facts, interprets ambiguous business input, and helps select the next tool. Laravel remains the final authority for permissions, data integrity, and workflow safety.

This separation made TingHao easier to test, explain, and audit.

What's next for TINGHAO - Autopilot Agent Inventory System

Our next steps are:

  • verify a custom email domain for direct production supplier delivery;
  • add Resend delivery, bounce, and failure webhooks;
  • improve demand forecasting using more historical sales and stock-movement data;
  • add supplier reliability scoring based on lead time, shortages, damage, and returns;
  • support supplier response parsing from email;
  • add festival, promotion, and seasonal demand signals;
  • introduce multi-branch and multi-tenant support;
  • add HTTPS through a production domain;
  • provide configurable approval policies for different purchase values;
  • evaluate prediction accuracy using real bakery operational data;
  • expand TingHao to cafés, restaurants, minimarkets, and other inventory-dependent small businesses.

Our long-term vision is for TingHao to become a safe procurement co-pilot that continuously watches operations, predicts risk, prepares the next action, and keeps humans in control of important business decisions.

Built With

Share this project:

Updates