← Back to Blog
·7 min read·

Agentic Workflows That Don’t Break: Tool Calling, Human-in-the-Loop, and the Seams Between Systems

An "AI agent" that automates a business process is not one model call - it is context engineering, tool/function calling, structured outputs validated before they touch a real API, embeddings and a vector database when search is genuinely the job, and a human checkpoint before anything irreversible ships. What actually breaks in these builds, and where I put the human back in.

AI AgentsWorkflow AutomationTool CallingHuman-in-the-LoopVector DatabasesContext Engineering

Business process automation and an AI agent get sold as the same thing, and they are not. Automation is a fixed pipeline: step two always follows step one the same way. An agent is a loop where the model decides which step comes next, based on what a tool call just returned. Both have a place - most of what a business actually needs is automation with one or two agentic decision points, not an agent making every call.

The architecture underneath either one is what determines whether it survives contact with real data: how you feed the model context, how you get an answer back in a shape your code can trust, how the model reaches into other systems, and where a person still has to say yes. That plumbing, not the model choice, is what I spend most of a project on.

1. Context engineering: feeding the model the right slice, not everything

Context engineering is the unglamorous work of deciding what the model sees on a given call - which records, which prior turns, which instructions - and, just as important, what it does not see. Dumping an entire customer history or a full document into the prompt every time is not thoroughness; it is noise that pushes the actual question further from the model’s attention and quietly inflates cost on every call.

The pattern that holds up is closer to a search problem than a memory problem: retrieve the two or three records relevant to this specific step, summarize what came before instead of replaying it verbatim, and let the agent ask for more only when it needs it. A workflow that reliably pulls the right five lines out of ten thousand beats one that stuffs all ten thousand in and hopes.

2. Structured outputs and tool/function calling are the actual interface

A model that replies in free text and gets parsed with a regex is where these builds quietly fail in production. Structured outputs - a JSON Schema the model is forced to answer inside - and tool/function calling - the model requesting a specific function with typed arguments instead of describing an action in prose - are what let your code trust a response enough to act on it without a human re-reading every output.

I validate the schema on the way out of the model and again before it reaches a real system, since a model can produce syntactically valid JSON that is still wrong for the business rule at hand - a negative quantity, a date in the past, a currency the account does not support. The schema catches shape errors; a second, boring validation layer catches the ones that are valid JSON and still wrong.

3. Embeddings and a vector database - only when search is the actual job

Embeddings and a vector database earn their place when the task is genuinely retrieval: find the three support tickets closest to this new one, find the clause in a contract closest to this question. They are the wrong tool for a fixed, small set of records a normal database query already answers - I have seen a vector database bolted onto a workflow that had eleven possible categories, where a lookup table would have been faster, cheaper, and easier to debug.

When it is the right tool, the part that actually needs care is not the embedding model - it is what gets chunked, how, and how fresh the index stays after the source document changes. A vector search over stale chunks gives a confident, wrong answer, and nothing in the agent’s output tells you it happened.

4. Human-in-the-loop and API orchestration: where it actually breaks

The failure I see most is not the model reasoning badly - it is the seam between two systems: an API call that times out and the agent retries it twice, sending a duplicate order; a webhook that fires before the previous step finished writing; a tool call that succeeds on the vendor’s side but the response the agent receives says it failed. Orchestrating calls across CRM, billing, and email means deciding what happens on a timeout or a partial failure before it happens in production, not after.

Everything that sends money, deletes a record, or emails a customer gets a human confirmation step before it fires - not because the model is untrustworthy in general, but because the cost of a wrong automatic action is asymmetric with the cost of one extra click. I’d rather a person approve twenty correct actions a day than have the agent auto-send one wrong invoice.

Conclusion: the agent is the easy 10%

Picking a model and writing the first prompt is genuinely the easy part of an agentic workflow. The context that gets fed in, the schema that gets validated, the vector search that only runs when it should, the retry logic across three APIs, and the one step a human still approves - that is the other 90%, and it is what decides whether the automation still works on a Tuesday six months from now with data nobody tested against. Write through the form with the process you want automated, and I’ll tell you which 10% is the agent and which 90% is the part that actually needs building.

Ready to discuss your project?

I'm a senior web engineer specializing in React and Next.js - available for freelance projects worldwide.

Location

Kyiv, Ukraine

Telegram

Contact me

WhatsApp

Contact me