Skip to main content
Back

XianyuAutoAgent Puts an AI Agent in Charge of Your Resale Store

XianyuAutoAgent is a free, open-source Python bot that handles Xianyu marketplace negotiations and customer service 24/7 using LLM-powered expert routing

Pro

Repo, Full Access
  • What it is: XianyuAutoAgent is a free, open-source Python bot for 24/7 automated selling on Xianyu (China's 300M-user secondhand marketplace).
  • Multi-expert routing: Incoming buyer messages are classified by intent and routed to one of three specialist agents: Price Expert, Tech Expert, or Customer Service.
  • Smart bargaining: The Price Expert runs a configurable tiered discount strategy, automatically negotiating down to a preset price floor without human input.
  • Any LLM backend: Works with any OpenAI-compatible API — Qwen (default), GPT-4o, DeepSeek, or local models via Ollama.
  • Human takeover mode: Sellers can switch between AI and manual mode at any time with a single keyword, without stopping the bot.
  • Key caveats: Cookie-based auth requires manual refresh on session expiry; project may be discontinued due to platform ToS gray area.

XianyuAutoAgent is an open-source Python project that puts an AI agent in charge of your secondhand storefront on Xianyu (also known as Goofish) , Alibaba's peer-to-peer resale marketplace. The bot handles buyer inquiries, negotiates prices, and answers technical questions around the clock, without you touching your phone. With nearly 6,000 GitHub stars and over 1,000 forks, it has clearly struck a nerve.

The market it targets is enormous

Xianyu (Idle Fish) is China's largest resale app, with over 300 million registered users. As of March 2025, its monthly active users reached 209 million, up 19% year-over-year. With tens of millions of active listings spanning 30+ categories , electronics, fashion, collectibles, home goods, and more , it is the dominant C2C resale platform in China. The problem for individual sellers is that Xianyu is fundamentally a negotiation-heavy marketplace: buyers haggle, ask technical questions, and expect fast replies. Miss a message and you miss the sale.

Three specialized agents, one router

The core architecture is a lightweight multi-agent system built on top of any OpenAI-compatible LLM API. Rather than routing every buyer message to a single general-purpose model, XianyuAutoAgent classifies each incoming message by intent and dispatches it to the most appropriate specialist. Think of it as a tiny software-level Mixture-of-Experts , instead of learned neural routing, it uses prompt engineering and rule-based logic to decide which agent fires.

The three specialized agents are:

  • Price Expert , handles bargaining with a configurable tiered discount strategy. It can automatically lower the price in steps based on buyer pressure, while staying within your preset floor.
  • Tech Expert , answers product-specific technical questions. It has web search integration, so it can look up specs or comparisons in real time rather than hallucinating.
  • Default Customer Service , covers everything else: shipping questions, condition queries, general chat.

A fourth prompt file, classify_prompt.txt, drives the intent router itself. Every incoming message first hits this classifier, which decides which expert to invoke. The system is powered by a large language model that can understand all kinds of questions from buyers while remembering previous chat content, making conversations more coherent and natural.

Tech expert agent responding to a detailed speaker spec comparison question in Chinese

Context memory and human takeover

The system stores the full conversation history per buyer and feeds it as context on every LLM call , a simple but effective approach to keeping multi-turn conversations coherent. There is also a manual override: the bot stays online 24/7 responding to buyer messages in real time, but sellers can switch to human mode at any point by typing a configurable keyword (default: a period "."), and switch back to AI mode the same way. This lets you jump in for high-stakes negotiations without killing the automation entirely.

The roadmap lists several planned upgrades:

  • RAG (Retrieval-Augmented Generation) knowledge base for product-specific Q&A
  • Sentiment analysis to detect frustrated or aggressive buyers
  • Market price comparison to inform negotiation strategy
  • DingTalk integration and a web management dashboard

Getting it running

Setup is straightforward for anyone comfortable with Python. You clone the repo, install dependencies, and fill in a .env file with four required values:

API_KEY=your_llm_api_key
COOKIES_STR=your_xianyu_web_cookies
MODEL_BASE_URL=https://your-llm-endpoint
MODEL_NAME=your-model-name

The cookies are grabbed from your browser's DevTools (Network tab, any Fetch/XHR request on the Xianyu web app). The default model is Qwen (Tongyi Qianwen), but any OpenAI-compatible endpoint works , GPT-4o, DeepSeek, local Ollama, whatever you prefer. Then it's just python main.py. The code is free and open, and users can download, modify, and deploy it. It is easy to install and suitable for individuals or small teams.

What it costs

The project itself is free and open source, downloadable directly from GitHub. Your only real cost is LLM API usage , which for a typical secondhand seller handling dozens of conversations per day will be negligible with a cheap model like Qwen or DeepSeek. The official setup guide (in Chinese) walks through the full process step by step.

Where it shines and where it doesn't

The standout feature is the Price Negotiation Expert, which automatically handles bargaining and implements tiered discounts based on preset strategies , ensuring you don't lose money while closing deals. The tech expert with live web search is also genuinely useful for sellers listing electronics, where buyers routinely ask detailed spec questions.

The limitations are real though. The cookie-based authentication is fragile , Xianyu sessions expire, and you'll need to refresh them manually. The project's own README notes that the team may stop updates or delete the project at any time due to the gray-area nature of automating a platform's private API. There's also no multi-account support yet, and the web management dashboard is still on the roadmap.

The bigger pattern

In today's digital marketplace, automating secondhand trading platforms gives sellers a real competitive edge. XianyuAutoAgent is a clean, practical example of a pattern that's becoming increasingly common: rather than building one monolithic agent prompt, you decompose the problem into specialized sub-agents and route between them. The implementation here is simple , prompt-based classification, not learned routing , but it works, and the architecture is easy to extend. For anyone building customer-service agents on top of LLMs, the repo is worth reading as a concrete reference implementation.