Robotinc

Part 5: Building with Strands Agents

We have secure device communication, but we’re still sending JSON. Let’s add the AI layer.

Model Choice: Amazon Nova Lite

Bedrock has many options:

Nova Lite is the “just right” for device control.

Strands Agents SDK

Strands is hitting the headlines, an open source SDK for building AI agents. AWS teams use it in production (Q Developer, Glue).

Why Strands:

The Goal

Stop sending {"action":"color","r":255,"g":0,"b":0}. Start saying:

Agent handles intent, RGB conversion, and MQTT.

Architecture

Architecture

Flow:

  1. Natural language → Bedrock
  2. Colour extraction → specialised sub-agent
  3. RGB conversion → Python color library
  4. MQTT publish → AWS IoT Core
  5. State queries → DynamoDB via IOT rules

State Logging via IoT Rules

IoT Rules are serverless event handlers. Our setup:

Why DynamoDB? Agent can query “What colour is the device?” without tracking state itself. Devices publish, Lambda logs, agent queries. Clean separation.

Multi-Agent Pattern

Main Agent routes requests to tools:

Why Tools Stop Hallucination

Without tools, LLMs make stuff up:

With tools:

The agent can only do what its tools allow.

Colour Extraction Sub-Agent

Specialised agent extracts CSS/X11 colour names:

Keeps the main agent focused on routing.

Agent Implementation

The complete agent code is in components/edge-agent/agent.py. Here are the key implementation patterns:

Prompt Engineering with XML

XML-structured prompts:

<routing_rules>
  <color_control>
    <triggers>"turn", "make", "change", "set"</triggers>
    <tool>color_control</tool>
  </color_control>
</routing_rules>

<critical_rule>
You MUST return ONLY the exact tool output.
</critical_rule>

XML works because LLMs parse structure better than prose. Plus it’s easy to version control.

Guardrails

Physical AI needs constraints:

Tool-Based: Agent can only execute defined tools. No direct hardware access.

Output Validation:

<critical_rule>
You MUST return ONLY the exact tool output. 
Do NOT add commentary.
</critical_rule>

Prevents inventing results.

Error Handling: Tools return real errors. Failed MQTT publishes are reported accurately.

State Verification: Device status from DynamoDB, not agent memory. Colour conversion uses deterministic library.

Strands vs Bedrock Agents Console

Strands: Code-first, version control, deploy anywhere

Bedrock Console: Visual builder, quick prototyping, no code

We chose Strands for developer experience and flexibility.

Next: Edge Deployment

We’re done with local development. Time to deploy to the edge with CDK, Greengrass, and containers.

Part 6: Edge Deployment with CDK and Greengrass →