Back to list

Context, not control: a context-driven autonomous Q&A system

Jim Lin
AGITech

Lately I've been building LetPot's customer support Q&A system. More than 200 knowledge documents, covering product specs, a plant encyclopedia, FAQs, and the official blog. The goal is to let the AI answer users' questions about using the devices and growing plants, on its own.

This project gave me the chance to actually ship and test an idea I'd had for a while.

When I took Andrew Ng's Agentic AI course late last year, the word "agentic" had only just entered the conversation, and there wasn't even agreement on how to define it. Andrew's definition:

Agentic AI is a new way of building software: using large language models (LLMs) to carry out some or all of the steps in a complex task. Unlike single-response prompting, an agentic workflow lets AI plan multi-step processes, execute iteratively, and improve its output through reflection and tool use.

The course was eye-opening, and it planted a seed: I figured that as agent capabilities improved, this day would come. I didn't expect that right at the start of 2026, with the release of Claude Opus 4.5 as the marker, people would realize models' agentic capabilities were already strong enough to run long-horizon tasks on their own and complete complex projects. Then came Claude Code, OpenClaw, Hermes Agent, and nearly every big company launched its own Claw or agent product, with agents of every kind popping up one after another. The mainstream is embracing this paradigm.

From pipeline to agent

In the Agentic AI course on DeepLearning.AI, Andrew Ng covers four core design patterns:

  • Loop (iterative execution): not one-shot generation, but a multi-step loop
  • Reflection (self-review): the AI critiques its own output and keeps improving it
  • Tool Use: it can call external databases, search engines, code execution, and so on
  • Planning: breaking a complex task into executable steps
  • Multi-agent Collaboration: several specialized AI systems working together to complete a complex workflow

The course implements everything in plain Python, with no framework, laying every step out in the open. What struck me most wasn't any particular pattern but the paradigm shift in how the whole system is architected.

The traditional approach is a pipeline workflow: user input → intent recognition → routing → retrieval → generation → filtering → output. Every step is deterministic and the flowchart is crystal clear. It's very engineered, but it also means every new requirement changes the flow, and every edge case adds a branch.

An agentic workflow is completely different. You don't draw a flowchart. You give the AI tools and context, then let it decide how to proceed. You give up some of the demand for deterministic output, and in exchange you get the ability to adapt to new situations.

The phrase "Context, not control" is borrowed from Netflix's management philosophy. Don't micromanage; provide ample context so people (or AI) can make good decisions on their own.

What an agent loop really looks like

There are plenty of agent frameworks out there: LangChain, LlamaIndex, and local coding agent frameworks like pi agent, the one underneath OpenClaw. I ended up choosing the Vercel AI SDK, for very specific reasons.

This project needs to be deployed as a standalone, stateless API service with strict security requirements, completely isolated from the file system and operating system. Frameworks like pi agent are designed from the ground up for local development environments: they can read and write files, run shell commands, and drive a browser. But in an online customer support setting, every access to a "file" should be a database query, and the agent shouldn't touch anything on the host machine.

I'd tried LangChain before. Orchestration was complex and slow to build, debugging was hard, and most importantly, it adapted poorly to new requirements. Every change in business logic meant rewiring.

What draws me to the Vercel AI SDK is how flexibly you can customize the loop. You can decide exactly which tools to use, the prompt for each stage, and the hooks and logging that run after each step. It doesn't make decisions for you, but it exposes every control point you need to make them. That opens up a lot of possibilities for observability.

Building the agent loop with the Vercel AI SDK's streamText, the core code is actually very concise. You tell the SDK three things: which model, which tools, and what context. The rest loops automatically between the SDK and the LLM.

The whole flow is very simple; one diagram is enough to understand it. But it's exactly this simple loop that gives the agent room to show what it can do. The loop doesn't need a single line of if/else for orchestration. The LLM decides which tools to call, how many times, and when to stop. The SDK only executes and passes things along.

When does the loop stop? In two cases: the LLM decides it can answer (it returns text instead of a tool call), or it hits the maximum number of steps you set. To prevent infinite loops, on the last step I force a switch to "no tool calls allowed" mode, which pushes the LLM to converge on an answer. This is one of the few places where I deliberately impose control.

Tools aren't instructions, they're capability descriptions

This is the most counterintuitive part of the agentic approach.

The LLM can't see your code. It only sees the tool's description (descriptive text) and the parameter schema (structure definition). Those two things are the entire basis for the LLM's decisions.

Take my search tool. Its description says: "Returns titles, summaries, and relevance scores. Use get_page to read full content."

That sentence is dense with information. It tells the LLM: search only returns summary-level information, and if you need the full content, you should follow up with get_page. From that one sentence the LLM learns how the two tools work together, and then chains them on its own at runtime.

I don't need to write orchestration logic like "if search returns results, call get_page to fetch the details." The LLM infers this collaboration pattern from the semantics of the description.

A good description is a form of context engineering. You're using natural language to teach the AI when to use which tool, and how the tools work together.

Watching the AI decide and act

The first time the whole flow ran end to end, what really surprised me wasn't the quality of the final answer but the AI's decision process.

Turn on the reasoning trace (DeepSeek's thinking mode) and you can see what it's thinking. Beyond the reasoning, the input parameters, return values, and latency of every tool call are visible in real time. Faced with a user's question, its line of thought looks a lot like what a person would do: first work out what the question is really about, run a coarse search over the index to find related topics, run a fine search to locate the specific source text, then reflect on whether it has enough information to answer. If not, it keeps searching along other dimensions. And before outputting, it checks once more that it actually answered what the user asked.

The whole thing runs on DeepSeek V4 Flash, and it's very fast.

Most importantly, the process is fully observable. Every step of the AI's reasoning, every tool call, and every intermediate result is recorded. Complex answers leave a trail. That's the key to ongoing optimization. If an answer is wrong, I can trace back to see exactly which step had the wrong information or made the wrong call, instead of guessing at a black box. Only with observability can you find where the problem is, and only then can you improve the knowledge base, debug tool calling, or refine the system prompt with more requirements and constraints.

I manage the context, the AI makes the decisions

In this architecture, the developer's job has fundamentally changed. I'm no longer writing business logic and control flow; I'm doing context engineering.

The system prompt isn't a list of instructions. It's the AI's sense of identity and its behavioral boundaries. It tells the AI "who you are", "where your knowledge comes from", and "what to do and what not to do". Add the tool descriptions, plus the user's message history and account information, and these three make up the entire context the AI uses to decide.

Context management is the biggest engineering challenge in this setup. At every step, the SDK resends the full message history to the LLM. That means the token cost of a multi-step agent accumulates. The request at step three includes every tool call and result from the first two steps.

In practice I've run into cases where a conversation got so long the LLM "forgot" the system prompt, or where long articles (with lots of noise) were noticeably slower to process. These are the physical limits of the context window. Next I'm considering splitting long documents into topic-based sections to reduce the noise in each retrieval.

The system's last line of defense

The system also has a checker tool, which does safety and fact-checking. This wasn't part of the design from the start; I added it while thinking through what a live production environment would need. It adds latency, but for applications that need safe, compliant output, it's close to mandatory.

For a customer support system facing real users, the AI's answers need a floor. Avoiding wrong, illegal, or non-compliant replies is the baseline. More importantly, you have to guard against prompt injection making the AI go off the rails.

My approach is to have the checker exist as an independent "external reviewer". Before outputting its final answer, the AI can call it to verify: Is the content safe? Are the facts backed by the knowledge base? Does it mention anything it shouldn't?

The key to this design is that it's also a tool, not a hard-coded post-processing step. The AI decides for itself when a review is needed. It may skip it for simple questions, and proactively call it for answers involving product specs or troubleshooting.

My take

After finishing this project, I have a few fairly firm conclusions.

On the boundary between agentic and orchestrated. Giving an agent room to act on its own means it's more likely to make mistakes, but it also means its ceiling is higher. It's a trade-off, but I think orchestrated AI will eventually disappear. As models get stronger and agent harness tooling matures, letting AI explore on its own within a controlled space will become the default. What matters more is giving it the right tools to try boldly within certain boundaries, not planning every step for it.

On observability. The agentic approach only works if you can see what the AI is doing. Reasoning traces, tool call logs, intermediate results: these aren't nice-to-haves, they're the foundation that lets the system keep improving. An agent system without observability is just a fancy black box, and harder to debug than a traditional pipeline.

On the possibility of evolving. The current system is "static": a fixed knowledge base, fixed tools, no learning from interactions. But an agentic architecture naturally leaves room to evolve. Give the agent memory (remembering the user's devices and preferences), knowledge gap detection (proactively flagging what's missing from the knowledge base), and strategy learning (adjusting its search strategy based on eval results), and it can go from a "static tool" to "a partner that gets smarter the more you use it". Look at the "closed learning loop" idea in Hermes Agent, where the agent creates skills from experience on its own and improves itself through use. That's the space for imagining the next stage.

One last point. Andrew Ng stresses one thing in the course: the biggest predictor of whether you can successfully build an agent system isn't technical skill, but whether you're disciplined about evals and error analysis. I feel this deeply. Let eval data guide what you change instead of guessing by intuition; that principle applies to agent development just as it does to traditional software. This project also has a complete eval system built in, which is crucial for iterating on the agent continuously.

You can only solve a problem once you can see it.

References