Rebuilding an AI‑Powered Shopping Scene Generator with LangGraph, Agent Skills, and Planner

This article details how a low‑code e‑commerce workflow was migrated to a modular LangGraph architecture, introducing Agent Skills, an A2A protocol, and a Planner node to enable multi‑turn natural‑language scene creation, product matching, and persistent storage while leveraging AI coding tools for rapid development.

Alibaba Cloud Developer
Alibaba Cloud Developer
Alibaba Cloud Developer
Rebuilding an AI‑Powered Shopping Scene Generator with LangGraph, Agent Skills, and Planner

In the AI‑driven e‑commerce era, operators need to generate personalized shopping scenes from a single natural‑language prompt, automatically producing titles, descriptions, tags, and linking relevant products. The original low‑code orchestration platform struggled with scalability, flexibility, and complex integrations, prompting a migration to a LangGraph‑based solution.

Project Background and Challenges

The system must understand user intent, generate structured scene data, create secondary tags, search for matching products, and output a complete template ready for deployment. Key challenges include multi‑turn dialogue, context management, token consumption, heterogeneous protocol integration (MCP, HSF, HTTP), and ensuring reliable, extensible workflows.

Core Architecture Upgrade

We rebuilt the system using LangGraph , which abstracts AI agent execution as a directed graph, allowing each node to encapsulate specific logic and share state via TypedDict. This provides clear code structure, parallelism, error retry, and state persistence.

Agent Skills : Skills are modular capability packages (e.g., scene‑generation, product‑service, persistence) with standardized interfaces, enabling dynamic loading and reuse across agents.

Planner Node : Introduces a "plan‑first‑then‑execute" approach, generating a JSON‑formatted execution plan that lists required skills and inputs, preventing step omission and ensuring correct order.

Tool Integration : LangGraph natively supports MCP and other protocols, making external tool calls decoupled and reusable.

LangGraph architecture diagram
LangGraph architecture diagram

Agent Skills Design

Each skill resides under app/skills/ with a SKILL.md metadata file, scripts, and reference documents. The SkillLoader scans this directory at startup, aggregates metadata, and injects it into the planner prompt.

# 传统做法:多个工具混在一起
tools = [
    generate_scene_blueprint,
    process_scene_blueprint,
    generate_scene_tags,
    search_products,
    filter_products,
    enrich_products,
    format_output,
    ...
]

Problems with the monolithic approach include difficulty managing tools, duplicated implementations, unclear responsibilities, and protocol heterogeneity.

Planner Prompt

PLANNER_PROMPT = """You are a scene‑guide planner. First generate a structured execution plan.
Output must be a JSON array with fields: step, skill, inputs, expected.
Constraints:
1) Must cover: blueprint generation → processing → tag generation → assembly → formatting → persistence.
2) Include product‑search step using product‑service skill.
3) End with persistence step using persistence‑service skill.
"""

The planner outputs a plan that the main agent injects into its system prompt, ensuring all required steps are executed.

AI Coding Accelerated Development

To meet a tight migration timeline, we combined two AI coding tools:

Cursor : Handles complex architecture design, DSL‑to‑LangGraph code generation, and scaffolding of skills.

AoneCopilot : Performs routine code completion, documentation lookup, and optimization within internal security constraints.

The migration workflow involved:

Exporting the existing low‑code workflow as a DSL (YAML) file describing nodes, edges, and parameters.

Using AI to parse the DSL, generate state definitions, node functions, and the overall StateGraph structure.

Creating a layered architecture (platform → application → workflow → service → persistence → external) and generating requirements.txt automatically.

DSL to LangGraph conversion flow
DSL to LangGraph conversion flow

DSL‑to‑Code Prompt

# DSL到LangGraph代码转换:AI Coding提示词指南
## DSL文件结构理解
```yaml
id: xxx
name: "工作流名称"
version: "1.0"
nodes:
  - id: "node_id"
    type: "node_type"
    data: # 参数
    position: {x: 100, y: 200}
edges:
  - id: "edge_id"
    source: "source_node_id"
    target: "target_node_id"
    sourceHandle: "output_handle"
    targetHandle: "input_handle"
```
步骤1: 解析DSL文件结构
步骤2: 生成状态定义
步骤3: 转换节点函数
步骤4: 生成路由函数
步骤5: 构建图结构
步骤6: 添加工程化支持
步骤7: 生成测试代码

Code Review and Refactoring

After core functionality was in place, AoneCopilot performed a full code review, uncovering duplicated logic, insufficient error feedback, and performance bottlenecks such as repeated traversal of skills during get_cached_tools(). The review led to:

Extracting common parameter‑completion logic into reusable utilities.

Enhancing error handling to surface messages to users.

Caching skill lookups to reduce runtime overhead.

Summary and Insights

The migration delivered a modular, extensible AI agent platform with the following benefits:

Capability Upgrade : Agent Skills provide richer tool usage.

Intelligent Planning : Planner reduces step omission and improves task completion by ~20%.

Standard Interoperability : A2A and MCP enable seamless integration with internal services.

Flexible Architecture : LangGraph’s graph and sub‑graph mechanisms support future complex workflows.

High Availability : Checkpoint savers ensure state reliability in distributed deployments.

AI coding tools accelerated development by roughly fivefold, improved code quality, and facilitated knowledge transfer through generated documentation. While AI excels at repetitive and standardizable tasks, deep business logic, performance tuning, and specialized integrations still require expert human oversight.

PythonDSLLangGraphAgent SkillsLow‑code migrationplanner
Alibaba Cloud Developer
Written by

Alibaba Cloud Developer

Alibaba's official tech channel, featuring all of its technology innovations.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.