Skip to content

Repository files navigation

πŸ€– AI Agent Workflow Automation Demo

CI Python FastAPI Playwright License

A production-style AI agent workflow engine that converts natural-language ERP tasks into executable browser automations with full audit trails, screenshots, and failure recovery.


🎬 What It Does

Type a task in plain English, and the Agent will:

  1. Understand your intent (create customer, search order, export report...)
  2. Plan a step-by-step workflow
  3. Execute via Playwright on a real web app
  4. Record every step with screenshots and logs
  5. Retry on failure and report results

Demo Task:

workflow-agent run "Create a new customer named Acme Corp with contact Alice, email alice@acme.com, and region APAC."

Output:

Task ID: task_a3f7d2e1
Status: success βœ…
Steps: 4
  - open_customer_page     β†’ success (320ms)
  - fill_customer_form     β†’ success (810ms)
  - submit_form            β†’ success (450ms)
  - verify_customer_created β†’ success (200ms)
Screenshots: 8 artifacts captured
Artifacts: artifacts/task_a3f7d2e1/

πŸš€ Quick Start (60 seconds)

Option A: Local Python

git clone https://github.com/13331800076/ai-agent-workflow-automation.git
cd ai-agent-workflow-automation
make install          # pip install + playwright browser
make test             # run 28 tests to verify
make cli-demo         # run a live demo task

Option B: Docker (Zero Setup)

docker-compose up -d
curl -X POST http://localhost:8000/tasks/run \
  -H "Content-Type: application/json" \
  -d '{"user_input": "Find order PO-1001"}'

πŸ“Έ Screenshots

MiniERP Dashboard Agent Execution Trace Task Artifacts
Dashboard Trace Artifacts

(Placeholder β€” run make cli-demo to generate your own screenshots)


πŸ—οΈ Architecture

User Task
   ↓
Task Parser (Intent + Entities)
   ↓
Workflow Planner (Step-by-Step Plan)
   ↓
Tool Router β†’ Playwright Executor
   ↓
MiniERP Web App (Real Browser Automation)
   ↓
Execution Logger + Screenshot Recorder
   ↓
Retry Handler / Failure Recovery
   ↓
Final Report + Artifacts

Why this matters: Most AI agent demos are "LLM β†’ Browser" black boxes. This project shows structured, testable, auditable agent engineering.


✨ Features

Feature Description
🎯 Task Parsing Rule-based NLU (v1) + extensible for LLM (v2)
πŸ“‹ Workflow Planning Fixed per-intent plans that are deterministic and testable
πŸ› οΈ Tool Calling 5 enterprise tools: customer, order, report, form, field-diff
🎭 Playwright Execution Headless browser automation with stable data-testid selectors
πŸ“Έ Screenshot Audit Before/after/failure screenshots for every step
πŸ“ Structured Logs Per-task JSON audit trail: plan.json, execution.log, result.json
πŸ”„ Retry & Recovery Automatic retry on element-not-found and download failures
πŸ§ͺ Tested 28 tests: unit, integration, E2E Playwright
🐳 Docker Ready docker-compose up and go
πŸ–₯️ CLI + API workflow-agent CLI + FastAPI REST endpoints

πŸ“¦ Use Cases

This project is a reference implementation for anyone building:

  • AI Agent platforms that need structured execution + observability
  • RPA / Automation tools with natural language interfaces
  • ERP/CRM automation with audit trails for compliance
  • Test automation frameworks that need visual traceability
  • LLM application engineering portfolios for job interviews

πŸ› οΈ Tech Stack

Layer Technology
Web App FastAPI + Jinja2 + SQLite
Agent Engine Python 3.11+ + Pydantic
Browser Automation Playwright (async)
Testing pytest + pytest-asyncio + pytest-playwright
Quality ruff + mypy
CI/CD GitHub Actions
Deployment Docker + Docker Compose

πŸ§ͺ Tested Task Examples

# 1. Create a customer
workflow-agent run "Create a new customer named Acme Corp with contact Alice, email alice@acme.com, and region APAC."

# 2. Search an order
workflow-agent run "Find order PO-1001 and summarize its status."

# 3. Export a report
workflow-agent run "Export the monthly sales report for May 2026."

# 4. Verify field values
workflow-agent run "Check whether customer Acme Corp has the expected region APAC and contact Alice."

# 5. Fill a form
workflow-agent run "Fill in the supplier onboarding form with company Acme Corp, tax ID TX-2026-001, region APAC."

🧰 API Endpoints

# Health check
curl http://localhost:8000/health

# Run a task
curl -X POST http://localhost:8000/tasks/run \
  -H "Content-Type: application/json" \
  -d '{"user_input": "Find order PO-1001"}'

# Get task result
curl http://localhost:8000/tasks/{task_id}

# Get task artifacts (screenshots + logs)
curl http://localhost:8000/tasks/{task_id}/artifacts

πŸ“‚ Artifact Structure

Every task generates a complete audit trail:

artifacts/task_a3f7d2e1/
β”œβ”€β”€ task.json              # Task metadata
β”œβ”€β”€ plan.json              # Generated workflow plan
β”œβ”€β”€ execution.log          # Step-by-step log with timestamps
β”œβ”€β”€ result.json            # Final result summary
└── screenshots/
    β”œβ”€β”€ 01_open_customer_page_before.png
    β”œβ”€β”€ 02_open_customer_page_after.png
    β”œβ”€β”€ 03_fill_customer_form_before.png
    β”œβ”€β”€ 04_fill_customer_form_after.png
    └── ...

πŸ—ΊοΈ Roadmap

  • v1.0: Rule-based parser + fixed workflow planner + Playwright tools + audit logs
  • v1.1: LLM-powered parser for flexible natural language
  • v1.2: LangGraph / LangChain integration for dynamic planning
  • v1.3: Attachment upload and approval workflow tools
  • v1.4: Configurable selectors (support multiple ERP systems)
  • v1.5: Web dashboard for viewing execution traces
  • v1.6: Batch task execution from CSV/JSON
  • v2.0: Cloud deployment with task queue (Redis + Celery)

🀝 Contributing

See CONTRIBUTING.md for guidelines.

Quick start for contributors:

make install    # setup
make test       # verify everything works
make lint       # code style
make type       # type checking

πŸ“„ License

MIT License β€” see LICENSE for details.


⭐ Star History

If this project helps you, please consider giving it a star! It motivates continued development and signals to the community that this is a useful reference.

Star History Chart


πŸ™ Acknowledgments

Built as a practical reference for AI Agent Engineer / Applied AI Engineer roles. Inspired by real-world needs for testable, auditable, and recoverable agent automation.

Not just a chatbot. A workflow engine.

About

A production-style AI agent workflow engine for automating ERP-like web operations with Playwright, tool calling, and audit trails.

Topics

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages