Summary
Implement the core ParcelAgent class — the autonomous AI entity at the heart of Sapient.X — using LangGraph for multi-step workflow orchestration and Sentient Foundation's sentient-70b model for reasoning, planning, and decision-making. Each parcel agent operates independently with full lifecycle management: it perceives metaverse environment data via MCP, reasons about optimal actions, executes trades and contract signings, and reflects on outcomes to improve future performance.
Roadmap Position: This is the foundational feature — all other features (#2 Wallet, #3 MCP Server, #4 Frontend) depend on the ParcelAgent being stable and testable.
Background & Motivation
Sapient.X is a platform where autonomous AI agents manage virtual parcels in a metaverse economy. Each agent must:
- Perceive its environment (parcel state, market prices, other agents)
- Reason about actions using a powerful LLM (Sentient Foundation
sentient-70b)
- Execute multi-step workflows (trade → sign contract → update state)
- Remember past decisions and learn from outcomes
LangGraph provides the stateful, cyclical graph execution model needed for this agentic loop. The perceive → analyze → plan → execute → reflect cycle maps directly to LangGraph nodes with conditional edges for dynamic routing.
Objectives
Technical Architecture
LangGraph Workflow Design
[START]
↓
[perceive] ← Fetches parcel data, market prices, agent messages via MCP tools
↓
[analyze] ← Sentient-70b analyzes current state vs. objectives
↓
[plan] ← Generates action plan (trade, hold, negotiate, sign contract)
↓
[execute] ← Calls MCP tools: initiate_trade, sign_contract, broadcast_message
↓
[reflect] ← Evaluates outcome, updates memory, logs reasoning
↓
[END] or back to [perceive] (loop)
Conditional edges:
analyze → plan (if action needed) or analyze → reflect (if hold/wait)
execute → reflect (always) or execute → perceive (if immediate re-evaluation needed)
reflect → END (if max iterations reached) or reflect → perceive (continue loop)
Agent State Dataclass
@dataclass
class AgentState:
parcel_id: str
agent_id: str
iteration: int
# Environment perception
parcel_data: dict
market_prices: dict
pending_messages: list[dict]
# Reasoning
analysis: str
action_plan: dict
# Execution results
executed_actions: list[dict]
trade_results: list[dict]
contract_signatures: list[str]
# Memory
short_term_memory: list[dict] # Last N decisions
long_term_summary: str # Redis-persisted summary
# Control
should_continue: bool
error_state: Optional[str]
Sentient Foundation Integration
from langchain.chat_models import ChatOpenAI
sentient_llm = ChatOpenAI(
base_url="https://api.sentient.xyz/v1",
api_key=os.environ["SENTIENT_API_KEY"],
model="sentient-70b",
temperature=0.1, # Low temp for consistent agent decisions
max_tokens=2048,
)
System prompt strategy:
- Role definition: autonomous parcel agent in metaverse economy
- Available tools description (MCP tool schema)
- Current state injection (parcel data, wallet balance, market conditions)
- Structured output enforcement (JSON action plan)
Implementation Plan
Phase 1: Core Agent Structure (Days 1-2)
Phase 2: LangGraph Workflow (Days 3-4)
Phase 3: Memory & Persistence (Day 5)
Phase 4: Testing & Integration (Days 6-7)
Technical Requirements
| Dependency |
Version |
Purpose |
| Python |
3.10+ |
Runtime |
langgraph |
>=0.0.40 |
Workflow orchestration |
langchain |
>=0.1.0 |
LLM abstraction |
langchain-openai |
>=0.0.5 |
Sentient endpoint |
redis |
>=5.0.0 |
Agent memory persistence |
pydantic |
>=2.0.0 |
State validation |
pytest-asyncio |
>=0.23.0 |
Async test support |
Environment Variables:
SENTIENT_API_KEY= # Sentient Foundation API key
SENTIENT_BASE_URL=https://api.sentient.xyz/v1
REDIS_URL=redis://localhost:6379
MCP_SERVER_URL=http://localhost:8000
MAX_AGENT_ITERATIONS=10
AGENT_DECISION_TIMEOUT=30
Acceptance Criteria
Files to Create / Modify
src/agents/
├── __init__.py # Export ParcelAgent, AgentState
├── parcel_agent.py # Main ParcelAgent class + LangGraph workflow
├── agent_state.py # AgentState dataclass + state helpers
├── memory.py # AgentMemory class (Redis-backed)
└── registry.py # NEW: Multi-agent registry and coordination
tests/unit/
├── test_parcel_agent.py # Agent lifecycle, workflow nodes, error handling
├── test_agent_state.py # NEW: State transitions and validation
└── test_memory.py # NEW: Redis memory persistence (mock Redis)
Estimated Effort
| Task |
Estimate |
| Agent state + lifecycle |
1 day |
| LangGraph workflow nodes |
2 days |
| Sentient Foundation integration |
0.5 days |
| Redis memory persistence |
1 day |
| Unit tests (90% coverage) |
1.5 days |
| Integration testing with MCP |
1 day |
| Total |
~7 days |
Related Issues & Dependencies
References
Summary
Implement the core
ParcelAgentclass — the autonomous AI entity at the heart of Sapient.X — using LangGraph for multi-step workflow orchestration and Sentient Foundation'ssentient-70bmodel for reasoning, planning, and decision-making. Each parcel agent operates independently with full lifecycle management: it perceives metaverse environment data via MCP, reasons about optimal actions, executes trades and contract signings, and reflects on outcomes to improve future performance.Background & Motivation
Sapient.X is a platform where autonomous AI agents manage virtual parcels in a metaverse economy. Each agent must:
sentient-70b)LangGraph provides the stateful, cyclical graph execution model needed for this agentic loop. The
perceive → analyze → plan → execute → reflectcycle maps directly to LangGraph nodes with conditional edges for dynamic routing.Objectives
ParcelAgentclass with full lifecycle managementsentient-70bmodelperceive → analyze → plan → execute → reflectTechnical Architecture
LangGraph Workflow Design
Conditional edges:
analyze → plan(if action needed) oranalyze → reflect(if hold/wait)execute → reflect(always) orexecute → perceive(if immediate re-evaluation needed)reflect → END(if max iterations reached) orreflect → perceive(continue loop)Agent State Dataclass
Sentient Foundation Integration
System prompt strategy:
Implementation Plan
Phase 1: Core Agent Structure (Days 1-2)
AgentStatedataclass insrc/agents/agent_state.pyParcelAgent.__init__()with config validationParcelAgent.start()/stop()/reset()lifecycle methodsPhase 2: LangGraph Workflow (Days 3-4)
perceive_node()— calls MCPget_parcel_data,get_market_price,get_world_stateanalyze_node()— Sentient-70b reasoning with structured outputplan_node()— action sequencing and priority rankingexecute_node()— MCP tool calls with retry logicreflect_node()— outcome evaluation and memory updatePhase 3: Memory & Persistence (Day 5)
memory.pywithAgentMemoryclassPhase 4: Testing & Integration (Days 6-7)
Technical Requirements
langgraphlangchainlangchain-openairedispydanticpytest-asyncioEnvironment Variables:
Acceptance Criteria
get_parcel_data,get_market_price)sentient-70bmodelperceive → analyze → plan → execute → reflectcycleparcel_agent.py,agent_state.py,memory.pyFiles to Create / Modify
Estimated Effort
Related Issues & Dependencies
perceive_nodeMCP tool calls)execute_nodein ParcelAgent)AgentStatedataclass)ParcelAgentto be stable)References