Skip to content

Nairobi · East Africa

Agentic AI

What Is Agentic AI and How Does It Work?

A practical guide to agentic AI: how agents plan, call tools and act inside business apps, where they fail, and how East African teams should adopt them safely.

TechBytes EA Engineering Team· · 11 min read

Humanoid robot assistant holding a tablet

Most organisations have now used a chatbot that answers questions. Far fewer have deployed software that can take a goal, decide which systems to touch, carry out the steps and report back. That second category is agentic AI, and it changes the engineering problem from "generate good text" to "take safe, auditable actions". This guide explains how agents actually work under the hood, where they are reliable today, where they are not, and how to decide whether a workflow in your business is a good candidate.

Key takeaways

  • An AI agent is a loop: a language model decides on the next action, your code executes it through a tool, and the result is fed back until the goal is met or a limit is reached.
  • The model never touches your systems directly. Every action passes through tools you define, which is where permissions, validation and audit logging belong.
  • Agents suit tasks that are multi-step and hard to script in advance, but where mistakes can be caught and reversed. Fixed, predictable processes are usually better served by ordinary automation.
  • Reliability comes from narrow tool scopes, explicit approval gates for consequential actions, and evaluation sets built from real cases, not from clever prompts.
  • In East Africa, design for intermittent connectivity, mobile-money integrations, the Kenya Data Protection Act 2019 and cost in KES, not just USD per token.

From chatbots to agents: what actually changed

A traditional chatbot takes text in and returns text out. Even a very capable one leaves the human to copy the answer into the ERP, send the email or reconcile the payment. Agentic systems close that gap by giving the model a set of tools: typed functions such as lookup_customer, check_stock, create_invoice or send_whatsapp_template. The model can request a tool call with structured arguments; your application runs the function and returns the result.

Three capabilities matured together to make this practical:

  1. Reliable structured tool calling. Modern model APIs return tool requests as structured JSON that can be validated against a schema, rather than free text you have to parse.
  2. Longer context and better planning. Models can hold a task description, policy documents and the history of several tool calls in one working context, and revise their plan when a step fails.
  3. Standard integration protocols. The Model Context Protocol (MCP) and similar conventions let one set of tool definitions serve several agent hosts, which reduces bespoke glue code.

None of this makes the model "autonomous" in a human sense. It is a probabilistic planner sitting inside deterministic software you control.

Three colleagues working together on laptopsSuccessful AI projects pair a technical team with the people who own the process.

How an agent works: the core loop

Every agent framework, whether a vendor platform or a hundred lines of Python, implements some version of this loop:

            +------------------------------+
            |  Goal + system instructions  |
            +--------------+---------------+
                           |
                           v
   +--------------->  LLM: decide next step  -------------+
   |                       |                              |
   |              tool call requested?                    |
   |                 yes   |    no                        |
   |                       v                              v
   |        Guardrail: validate args, check      Final answer / handoff
   |        permissions, require approval?        to a human
   |                       |
   |                       v
   |           Execute tool (API, DB, RPA)
   |                       |
   |                       v
   +------  Observation appended to context
            (with step counter and cost budget)

1. Perception: what the agent knows

The agent's "knowledge" at any step is whatever is in its context: the system prompt (role, policies, tone), the user's request, retrieved documents, and the results of previous tool calls. If the price list is not retrieved, the model does not know it. Most agent failures in production trace back to missing or stale context rather than poor reasoning.

2. Planning and decision-making

Given that context, the model chooses: answer now, call a tool, or ask a clarifying question. Better models break a goal like "prepare a quote for 40 laptops for a Mombasa client, delivered next week" into sub-steps: check stock, check the client's pricing tier, compute delivery from the Nairobi warehouse, generate the quote. You can see this reasoning in logs, which is invaluable for debugging.

3. Action through tools

Tools are where the agent meets the real world. A tool is just a function with a name, a description written for the model, and an input schema. Good tool design is the single biggest lever on agent quality:

  • Narrow scope. create_draft_quote is safer than execute_sql.
  • Clear descriptions. Explain when to use the tool and what it returns, including error cases.
  • Idempotency. A retried create_invoice call should not produce two invoices.
  • Structured errors. Return "customer not found" as data the model can reason about, not as a stack trace.

4. Observation and iteration

The tool's output goes back into the context and the model decides again. This is what allows recovery: if check_stock shows only 25 units in Nairobi, the agent can check the Kampala warehouse or propose a partial delivery. It is also what makes cost unpredictable, because each iteration resends the growing context. Production agents always carry a step limit and a token or currency budget.

5. Memory

Within one task, memory is the conversation history. Across tasks, you add explicit stores: a CRM note, a vector index of past tickets, or a simple key-value record of customer preferences. Treat long-term memory as personal data under the Data Protection Act, with retention rules and a way to delete it on request.

Agents vs workflows vs RPA

Not every automation problem needs an agent. A useful way to decide is to compare the options directly.

ApproachWho decides the stepsBest forWeakness
Scripted workflow (Zapier, n8n, Power Automate, custom code)The developer, in advancePredictable, high-volume processes such as sending an M-Pesa receipt after paymentBreaks when inputs vary or exceptions appear
RPA (UI automation bots)The developer, by recording clicksLegacy systems with no API, such as older desktop accounting packagesFragile when screens change; no judgement
LLM inside a workflowThe developer, with the model handling one fuzzy stepClassifying emails, extracting fields from invoices, drafting repliesLimited to the step it is placed in
AgentThe model, within tools and limits you setMulti-step tasks with variable paths: triage, research, quoting, reconciliation exceptionsHigher cost and latency; needs evaluation and guardrails

In practice, the strongest systems combine these. A deterministic workflow handles the happy path, and an agent is invoked only for exceptions that would otherwise land on a human's desk.

Where agents work well today

Based on what we see in delivery work, agents earn their keep when four conditions hold: the task is multi-step, the inputs vary, the outcome justifies the extra cost, and errors can be caught before they cause harm.

  • IT service desk triage. Reading a ticket, checking device inventory and the user's recent sign-ins, resetting a password through an approved API, and escalating with a summary when it cannot resolve.
  • Sales quoting. Checking stock, applying the correct price tier, adding VAT, and producing a draft quote for a salesperson to approve.
  • Finance exceptions. Matching M-Pesa paybill statements against invoices when the account reference was mistyped, and proposing matches for an accountant to confirm.
  • Procurement research. Comparing supplier quotes against specifications and flagging mismatches.
  • Software engineering. Coding agents that read a repository, make a change, run tests and open a pull request for review. This is currently one of the most mature agent categories. See our guide on how to build your first AI agent for the mechanics.

Where agents struggle

Be sceptical of any proposal that puts an agent in sole control of the following:

  • Irreversible money movement. Initiating B2C or B2B payments through the M-Pesa Daraja API should always require human approval or hard limits enforced in code, not in the prompt.
  • Tasks with no ground truth. If nobody can say whether the output was correct, you cannot evaluate or improve the agent.
  • Highly regulated decisions about individuals. Credit decisions, hiring and similar automated decision-making carry obligations under the Data Protection Act 2019, including rights relating to decisions based solely on automated processing.
  • Very long unattended runs. Errors compound across steps. A short loop with checkpoints beats a long autonomous run.

Overhead view of a developer workstation with code on two monitorsA typical engineering setup: editor, terminal and the running app side by side.

Architecture for an East African deployment

Agent architecture in Nairobi, Kampala or Dar es Salaam has a few regional realities that are easy to overlook.

Latency and model hosting. At the time of writing, the major model APIs are served from data centres in Europe, North America and elsewhere, and the nearest hyperscaler cloud regions are in South Africa and the Middle East. Each agent step therefore includes an international round trip. A ten-step agent can take tens of seconds end-to-end, which is fine for back-office work but poor for a live customer chat. Design for asynchronous completion: acknowledge the request, run the agent in the background and notify by SMS, email or WhatsApp.

Connectivity and power. Run the agent loop on a server, not on a user's laptop that might lose LTE coverage or power mid-task. Persist state after every tool call so a restart after a power cut resumes rather than repeats actions. Back the server with a UPS and, for on-premises hosting, a generator changeover that has been tested.

Data residency and the ODPC. Sending customer records to a model API hosted outside Kenya is a cross-border transfer under the Data Protection Act 2019. You need a lawful basis, appropriate safeguards, and you should be able to tell the ODPC where the data goes. Minimise what you send: pass a customer ID and the fields needed, not the whole record. Review guidance at odpc.go.ke.

Local integrations. The tools that matter most here are often M-Pesa (via Daraja), Airtel Money, KRA eTIMS invoicing, bulk SMS gateways and WhatsApp Business. Wrapping these as narrow, well-tested tools is usually more work than the agent itself, and it is the work that determines success.

Cost in KES. Token pricing is quoted in USD, and an agent that resends a large context on every step can cost far more than a single chat call. Budget per completed task, set hard caps, and check current pricing with your provider before committing to volumes.

A decision checklist before you build

Use this list with your operations and finance leads before approving an agent project:

  • Can you describe the goal in one sentence and define what "done correctly" looks like?
  • Do at least 50 real historical examples exist that you can use to test the agent?
  • Does a scripted workflow already handle 80 percent of cases, leaving the agent only the exceptions?
  • Is every consequential action (payments, deletions, external emails) behind an approval gate or hard limit in code?
  • Are tool permissions scoped to the minimum: read-only where possible, a dedicated service account, no shared admin keys?
  • Is every step logged with inputs, outputs and the model's stated reasoning, so you can audit an incident?
  • Has your data protection officer reviewed what personal data leaves your environment?
  • Is there a per-task cost ceiling and a monthly budget alert?
  • Is there a named owner who reviews failures weekly?

If you cannot tick most of these, start with a narrower workflow automation and revisit later.

Common mistakes

  • Giving the agent broad credentials. An agent with a database admin password will eventually do something you did not intend. Scope each tool to a dedicated, least-privilege account.
  • Putting business rules only in the prompt. "Never discount more than 10 percent" belongs in the create_quote function as a validation check. Prompts guide; code enforces.
  • Skipping evaluation. Teams demo an agent on five hand-picked cases and ship. Build an evaluation set from real tickets, invoices or emails and run it on every prompt or model change.
  • Ignoring prompt injection. Any text the agent reads, such as an email body, a supplier PDF or a web page, can contain instructions. Treat tool outputs as untrusted data and never let them expand the agent's permissions. The OWASP guidance on LLM applications is a good starting point.
  • No human fallback. Agents should hand off cleanly with a summary when they are unsure, rather than guessing.
  • Measuring cost per call instead of per task. A cheaper model that needs three retries is not cheaper.

FAQ

Is agentic AI the same as generative AI?

Agentic AI uses generative models, but adds tools, a control loop and state. Generative AI produces content; an agent uses that capability to decide and carry out actions in other systems.

Do I need my own GPU servers to run AI agents?

No. Most businesses call hosted model APIs and run only the orchestration code themselves, which needs modest compute. Self-hosting open-weight models is an option where data must stay on-premises, but it requires GPU hardware, reliable power and specialised skills that are still scarce locally.

How much does an AI agent cost to run?

It depends on the model, the number of steps per task and how much context is resent each step. Estimate tokens per task from a pilot, multiply by your provider's current published rates, add a margin for retries, and convert to KES. Prompt caching and smaller models for simple sub-tasks can reduce costs significantly.

It can be, but it is a cross-border transfer under the Kenya Data Protection Act 2019 and must meet its requirements, including appropriate safeguards and transparency with data subjects. Minimise the data sent and document the transfer in your records of processing.

What skills does my team need to build agents?

Solid backend engineering (APIs, authentication, logging), an understanding of your business process, and the discipline to build evaluation sets. Prompt writing matters, but it is a smaller part of the work than most people expect.

How TechBytes can help

We help organisations identify which workflows genuinely benefit from agents, then design the tools, guardrails and evaluation sets that make them dependable. That includes integrations with M-Pesa, eTIMS and your existing ERP or CRM, and a data protection review of what leaves your environment. If you want to scope a pilot, start with our AI and automation services or request a consultation.

WhatsApp