What is Context?
Context is everything for LoopOS AI. Context provides agents with the information they need to:
- Understand your business and use cases
- Make informed decisions
- Generate relevant responses
- Validate data against your catalog
All context must be managed and provided by LoopOS applications, particularly LoopOS Core. The AI server does not maintain business context independently.
Context Types
Business Context (loopos_core_context)
High-level description of your business/platform:
{
"loopos_core_context": "Circular economy marketplace for consumer goods in Portugal. Focus on electronics, furniture, and clothing. Active marketplace with pricing data and trends."
}
Best practices:
- Be specific about your business model
- Include geographic focus if relevant
- Mention key categories or product types
- Describe your marketplace characteristics
Item Context
Information about the current item being processed:
{
"agent_specific": {
"loopos_item": {
"item": {
"data": {
"id": 2069,
"product": {
"name": "iPhone 12",
"brand": "Apple"
},
"categories": ["Electronics", "Smartphones"]
},
"protocol_answers": {
"last_answers": [
{"question": "Condition", "answer": "Good"},
{"question": "Description", "answer": "Minor scratches"}
]
}
}
}
}
}
Session Context
Conversation history and state maintained across requests:
{
"session_id": "session-123",
"messages": [
{"role": "user", "text": "I want to sell an iPhone"},
{"role": "assistant", "text": "Great! Let me help you..."}
],
"session_extra_data": {
"core_id": "core123",
"script_id": "script456",
"item_id": "item789"
}
}
Agent-Specific Context
Service-specific parameters and configuration:
{
"agent_specific": {
"category_name": "Electronics",
"product_name": "iPhone 12 Pro",
"brand_name": "Apple",
"user_description": "iPhone em excelente estado"
}
}
Context Flow
Context flows through the system:
Request
↓
Service Context (initialized from request)
↓
Agent Context (passed to agent)
↓
Tools (context used in tool calls)
↓
Response (context included in output)
Providing Context
In API Requests
Include context in your API requests:
{
"language": "PT-PT",
"loopos_core_context": "Your business description here",
"agent_specific": {
"category_name": "Electronics",
"product_name": "iPhone 12"
},
"session_extra_data": {
"core_id": "core123",
"item_id": "item789"
}
}
Context from LoopOS Core
LoopOS Core provides context through:
- Settings: Business context stored in LoopOS Core settings
- Item Data: Current item information
- Catalog Data: Products, brands, categories
- Protocol Data: Protocol questions and answers
Context Best Practices
Be specific: Provide detailed, specific context rather than generic descriptions.
Include relevant data: Only include context that’s relevant to the current operation.
Maintain consistency: Use consistent context across related requests in a session.
Update context: Update context as items progress through workflows.
Context Examples
Example 1: Value Estimation
{
"loopos_core_context": "Portuguese circular economy marketplace, active used goods market with pricing data and trends",
"agent_specific": {
"loopos_item": {
"item": {
"data": {
"product": {
"name": "iPhone 12",
"brand": "Apple"
},
"categories": ["Electronics", "Smartphones"]
},
"protocol_answers": {
"last_answers": [
{"question": "Condition", "answer": "Grade B - Good condition"}
]
}
}
}
}
}
Example 2: C2C Descriptor
{
"loopos_core_context": "Portuguese marketplace for second-hand items",
"agent_specific": {
"category_name": "Electronics",
"product_name": "iPhone 12 Pro",
"brand_name": "Apple",
"user_description": "iPhone em excelente estado, pouco uso"
},
"images": ["https://example.com/photo.jpg"]
}
Example 3: ID Validation
{
"loopos_core_context": "Portuguese circular economy platform, ID validation for marketplace",
"agent_specific": {
"doc_type": "passport,id-card",
"name": "JOHN DOE",
"number": "123456789",
"validity": true
},
"images": ["https://example.com/id-front.jpg", "https://example.com/id-back.jpg"]
}
Context Limitations
Context size is limited by:
- Request size limits (default: 10MB)
- Token limits for LLM context windows
- Database storage for session context
Keep context focused and relevant to avoid hitting limits.
Context in Multi-Agent Workflows
In multi-agent workflows, context is passed between agents:
- Initial Context: Set in first request
- Context Updates: Tools update context (e.g.,
create_item adds item_token)
- Handoff Context: Context passed to next agent via handoff data
- Final Context: Final context included in response