Discovery
AI agents need to understand what tools are available. Shelfforce provides two discovery mechanisms:OpenAPI specification
The full OpenAPI 3.1 specification is available at:llms.txt
For LLM context injection, Shelfforce publishes anllms.txt file:
Recommended agent workflow
The standard workflow for an AI agent integrating with Shelfforce:1
Analyze
Submit a shelf image for analysis.
2
Poll or listen
Either poll
GET /api/v1/analyses/{id} until status is completed, or configure a webhook for analysis.completed.3
Extract
Read the product data from the completed analysis response. Parse brand names, facing counts, prices, and promotional status.
4
Report
Query share-of-shelf and store performance reports for aggregated insights.
5
Act
Based on the results, the agent can create tasks, flag compliance issues, or feed data into downstream systems.
Function calling schema
Here is an example tool definition for Claude or GPT function calling that covers the core analysis workflow:- Claude (Anthropic)
- OpenAI (GPT)
Idempotency keys
Idempotency is critical for AI agents, which may retry requests due to timeouts, network errors, or reasoning loops. Always include an idempotency key with analysis requests:Webhook-driven vs. polling
There are two patterns for handling asynchronous analysis results:Polling (simpler, good for agents)
Webhook-driven (more efficient, better for production)
analysis.completed, and your system receives the results as soon as they are ready — no wasted requests.
Error handling for agents
AI agents should handle Shelfforce errors gracefully:Example: Agent error handling loop
MCP server (coming soon)
A Model Context Protocol (MCP) server for Shelfforce is on the roadmap. This will allow Claude Desktop, Cursor, and other MCP-compatible clients to discover and use Shelfforce tools automatically.
Best practices for agents
Always use idempotency keys
Prevents duplicate analyses and wasted credits when agents retry requests.
Include metadata
Tag analyses with source, agent name, and context so you can trace which agent submitted which analysis.
Handle all error codes
Distinguish between retryable (429, 500) and non-retryable (401, 402, 403, 422) errors.
Cache analysis results
Analysis results are permanent. Store results locally to avoid redundant GET requests.
Use llms.txt for context
Include the llms.txt content in your agent’s system prompt for better API understanding.
Respect rate limits
Implement exponential backoff. Use batch endpoints to reduce request count.