Implement Observation Agent with Claude Sonnet 4 and BentoML Hook

implementationChallenge

Prompt Content

Implement the 'Observation Agent' using Mastra AI. This agent will simulate receiving input from a 'curious AI' camera/drone, which you will model as an inference endpoint deployed on BentoML Cloud (for this prompt, a simple function call will suffice, but conceptualize it as a BentoML service). The agent should use Claude Sonnet 4 to interpret observation data (e.g., 'item detected at location X') and update its internal memory. Integrate a simple tool to 'report_observation' to the Inventory Agent.

```typescript
import { createAgent } from '@mastra-ai/core';

// Simulate a BentoML inference call
async function callBentoMLInference(imageData: string): Promise<{ detected_item: string, location: string }> {
  // In a real scenario, this would be an HTTP call to your BentoML service
  console.log(`Simulating BentoML inference for image data: ${imageData}`);
  return { detected_item: 'SKU12345', location: 'Aisle 3, Shelf 5' };
}

const observationAgent = createAgent({
  name: 'observationAgent',
  llm: 'claude-sonnet-4',
  actions: {
    processObservation: async (ctx, imageData: string) => {
      const inferenceResult = await callBentoMLInference(imageData); // Call simulated BentoML service
      ctx.memory.set('last_observation', inferenceResult); // Update agent's memory
      // Use LLM to interpret and potentially call another tool/agent
      const response = await ctx.llm.chat([{
        role: 'user',
        content: `Interprete this observation: Item ${inferenceResult.detected_item} detected at ${inferenceResult.location}. What should I do?`
      }]);
      // Example tool call or message to another agent based on LLM's response
      // await ctx.send('inventoryAgent', { type: 'item_detected', payload: inferenceResult });
      return response.content;
    }
  },
  // ... other configurations like memory providers, etc.
});

// Example usage: observationAgent.actions.processObservation('drone_feed_001');
```

Try this prompt

Open the workspace to execute this prompt with free credits, or use your own API keys for unlimited usage.

Usage Tips

Copy the prompt and paste it into your preferred AI tool (Claude, ChatGPT, Gemini)

Customize placeholder values with your specific requirements and context

For best results, provide clear examples and test different variations