TECHNICAL BLOG
Deep Dives for Engineers
Detailed technical articles covering the real problems we solve in embedded systems, AI, and robotics engineering.
Detailed technical articles covering the real problems we solve in embedded systems, AI, and robotics engineering.
How to design, implement, and safely deploy multi-agent AI systems that can plan, use tools, delegate subtasks, and complete complex workflows with minimal human intervention.
A language model that answers questions is not an agent. An agent perceives its environment, forms goals, selects actions from a set of available tools, executes those actions, observes the results, and iterates until the goal is satisfied or it determines the goal cannot be met. The critical additions over a standard LLM call are: tool use, memory (working, episodic, semantic), and a control loop that continues across multiple inference steps.
The Reason + Act (ReAct) pattern is the foundational control loop for most production agents. At each step, the model generates a Thought (reasoning about current state and next action), an Action (tool call with parameters), observes the Action Result, and repeats until it can generate a Final Answer.
from langchain.agents import create_react_agent, AgentExecutor
from langchain import hub
from langchain_openai import ChatOpenAI
from langchain.tools import tool
@tool
def query_sensor_db(device_id: str, metric: str, hours: int) -> str:
'''Query historical sensor metrics from the IoT database.'''
# Implementation queries your time-series database
return fetch_metrics(device_id, metric, hours)
@tool
def trigger_diagnostic(device_id: str) -> str:
'''Trigger a remote diagnostic on the target embedded device.'''
return call_device_api(device_id, "diagnostic")
tools = [query_sensor_db, trigger_diagnostic]
llm = ChatOpenAI(model="gpt-4o", temperature=0)
prompt = hub.pull("hwchase17/react")
agent = create_react_agent(llm, tools, prompt)
executor = AgentExecutor(agent=agent, tools=tools, verbose=True, max_iterations=10)
result = executor.invoke({
"input": "Device RDK-GW-0042 reported high latency yesterday. Analyse the last 24h metrics and trigger a diagnostic if anomalous."
})
Complex workflows benefit from decomposition into specialised agents coordinated by an orchestrator. A supervisor agent receives the high-level goal, breaks it into subtasks, assigns each to a worker agent with the appropriate tools, collects results, and synthesises the final output.
from langgraph.graph import StateGraph, END
from typing import TypedDict, Annotated
import operator
class AgentState(TypedDict):
messages: Annotated[list, operator.add]
next_agent: str
def supervisor(state: AgentState) -> AgentState:
# Decide which worker agent to invoke next
response = supervisor_chain.invoke(state["messages"])
return {"next_agent": response.next}
def researcher(state: AgentState) -> AgentState:
result = research_chain.invoke(state["messages"])
return {"messages": [result]}
graph = StateGraph(AgentState)
graph.add_node("supervisor", supervisor)
graph.add_node("researcher", researcher)
graph.add_node("analyst", analyst)
graph.add_conditional_edges("supervisor", lambda s: s["next_agent"])
graph.set_entry_point("supervisor")
app = graph.compile()
Production agents need layered memory:
Autonomous agents that take real-world actions — executing code, calling external APIs, modifying databases — require explicit safety guardrails:
The failure mode of agentic systems is not usually the agent taking dramatically wrong actions — it is the agent taking many plausible-looking but subtly wrong actions that compound into a significant error. Observability and bounded autonomy are not optional.
Agentic AI is the frontier of applied LLM engineering. The patterns — ReAct, multi-agent orchestration, layered memory, tool use — are now well understood, but production deployment requires disciplined attention to safety, cost control, and observability. Start with single-agent systems on bounded tasks, validate the behaviour thoroughly, then expand to multi-agent architectures as you gain confidence in each component's reliability.
Continue reading — handpicked articles you might enjoy