Harvest - AI-Powered Agricultural Negotiation Platform

Inspiration

In Kenya and across Africa, smallholder farmers often struggle to negotiate fair prices for their crops due to information asymmetry, language barriers, and lack of market access. We envisioned Harvest as a training ground where farmers could practice negotiation skills with AI agents before entering real market transactions. By experiencing realistic voice-based negotiations in a safe environment, farmers can build confidence, learn effective strategies, and understand market dynamics—ultimately empowering them to secure better deals for their harvests.

What it does

Harvest simulates realistic agricultural negotiations through interactive voice AI. Users witness two AI agents—Halima (a maize farmer/seller) and Alex (a commodity buyer)—engage in natural, multi-turn negotiations over price, delivery terms, payment schedules, and transport responsibilities.

Key Features:

  • Real-time voice negotiation: Agents speak using distinct voices (Kora for Halima, Big Dicky for Alex)
  • Dynamic multi-lever bargaining: Negotiations consider price per kg, delivery inclusion, transport costs, and payment terms
  • Intelligent concession tracking: Agents make strategic compromises based on round progression and previous offers
  • Live transcript display: Real-time negotiation timeline with offer updates
  • Natural conversation flow: Agents speak conversationally, defending positions with realistic arguments (fertilizer costs, market conditions, cash flow constraints)

The platform demonstrates how AI can make agricultural market intelligence accessible and interactive, turning complex negotiations into observable, learnable experiences.

How we built it

Backend (Python + LiveKit Agents):

  • LiveKit Agents Framework: Orchestrated dual-agent architecture with separate sessions for voice attribution
  • Speech-to-Text: Deepgram for real-time transcription
  • LLM Reasoning: OpenAI GPT-4o-mini for agent decision-making and conversation
  • Text-to-Speech: Hume AI for expressive, natural-sounding voices
  • Voice Activity Detection: Silero VAD for turn-taking
  • FastAPI: REST endpoints for session management and offer updates
  • State Management: Shared negotiation state tracking rounds, offers, and concessions

Frontend (Next.js + React):

  • LiveKit React Components: Real-time voice streaming and connection management
  • Real-time Updates: WebSocket integration for live negotiation timeline
  • Modern UI: Tailwind CSS with responsive design
  • TypeScript: Type-safe development

Architecture Pattern: We evolved through multiple architectures, ultimately landing on a dual-session model where each agent maintains their own AgentSession for proper voice attribution, coordinated through a central orchestration loop that manages turn-taking, acceptance guards, and state synchronization.

Challenges we ran into

  1. Multi-Agent Orchestration: Coordinating two AI agents in real-time proved complex. We initially attempted a central orchestration loop, then event-driven handlers, before discovering the dual-session approach was necessary for proper speaker attribution.

  2. Conversation History Isolation: Our first single-session architecture with voice switching caused agents to share history correctly, but we lost speaker attribution in transcripts. The dual-session approach solved attribution but created the opposite problem—agents couldn't hear each other. We solved this by implementing careful state sharing and explicit offer tracking.

  3. Preventing Premature Acceptance: Agents would accept deals too quickly, ending negotiations before meaningful bargaining occurred. We implemented progressive acceptance thresholds that tightened over rounds and required minimum concession counts.

  4. Startup Synchronization: Ensuring Halima always spoke first without creating duplicate turns required careful orchestration guards, metadata-based job identification, and round-0 skipping logic.

  5. Agent Role Confusion: With shared conversation context, agents sometimes confused their roles (both acting as sellers). We strengthened persona instructions with explicit "CRITICAL: You are BUYING/SELLING" warnings.

Accomplishments that we're proud of

Built a fully functional voice-based dual-AI negotiation system - Two agents with distinct personalities, voices, and strategies negotiating naturally

Achieved realistic multi-turn bargaining - Agents make strategic concessions, defend positions with contextual arguments, and reach logical conclusions

Solved complex multi-agent coordination challenges - Navigated LiveKit's architecture to enable proper voice attribution while maintaining conversation continuity

Created an accessible agricultural tech demo - Demonstrates how AI can democratize market intelligence for underserved farming communities

Real-time interactive experience - Users can watch negotiations unfold live with transcripts, offer updates, and timeline visualization

What we learned

Technical Insights:

  • LiveKit Agents' dual-session architecture enables voice attribution but requires careful state management for inter-agent communication
  • Event-driven patterns in real-time AI systems are fragile; explicit SpeechHandle-based turn chaining provides better reliability
  • LLM persona instructions must be extremely explicit—even "obvious" role definitions can blur in multi-turn conversations
  • Progressive acceptance logic (thresholds that tighten over rounds) creates more realistic negotiations than static rules

Domain Knowledge:

  • Agricultural negotiations involve multiple interdependent variables (price, delivery, payment, transport)—not just single-dimensional bargaining
  • Smallholder farmers face unique challenges: information asymmetry, language barriers, and lack of practice opportunities
  • Voice-based AI can make market intelligence accessible to low-literacy populations

Development Process:

  • Rapid iteration through multiple architectural approaches taught us to validate assumptions early
  • Clear logging and state tracking were invaluable for debugging asynchronous multi-agent systems
  • Sometimes the "proper" architecture (single session) doesn't match real-world constraints (speaker attribution)

What's next for Harvest

Immediate Enhancements:

  1. User Participation Mode: Allow users to negotiate directly with AI agents, replacing one agent with human input
  2. Scenario Library: Pre-configured negotiations for different crops, regions, and market conditions
  3. Performance Analytics: Track user negotiation outcomes, identify improvement areas, and provide coaching feedback
  4. Multi-language Support: Swahili, Kikuyu, and other East African languages for broader accessibility

Long-term Vision:

  1. Mobile App: USSD/SMS integration for feature phone access in rural areas
  2. Real Market Data: Integrate live commodity prices to train agents on current market conditions
  3. Community Marketplace: Connect trained farmers with verified buyers for actual transactions
  4. Cooperative Negotiations: Enable group bargaining simulations for farmer cooperatives
  5. AI Coaching Assistant: Personalized negotiation tips based on user patterns and regional market trends

Impact Goal: Empower 10,000 smallholder farmers across East Africa with negotiation skills that increase their harvest income by an average of 15-20% within the first year.


Tech Stack

Built with: LiveKit • OpenAI • Hume AI • Deepgram • FastAPI • Next.js • TypeScript • Python

Built With

Share this project:

Updates