By nghxni

Technical article

Complex API integration on a solo budget: one agent, three tools, seven days

Solo founders and small teams do not need a big budget to wire AI into business systems. With the LightESB AiAgentDemoSrv pattern — a single HTTP entrypoint, a LangChain4j agent, and tagged tool routes — a production-minded integration loop runs on an all-open-source stack plus under $7 of model API credit.

The blocker is fragmentation, not budget

Most teams do not fail because APIs are missing — they fail because flows are fragmented: multiple endpoints with inconsistent payloads, business users who cannot call raw APIs, and growing maintenance cost from glue code. The AiAgentDemoSrv pattern standardizes the full loop: the user sends a natural-language intent, the agent selects and executes tools, and the system returns both a human-readable responseText and structured toolData.

The budget split is deliberately small: $0 for the open-source stack (LightESB, Apache Camel, LangChain4j), $3-$7 for a small LLM API top-up to test real tool calling, and $0 for local debugging and iteration. The goal is not scale on day one — it is a repeatable, demo-ready integration loop.

A minimal architecture you can copy

Single entrypoint

POST /api/ai/agent/chat — every client (web app, admin panel, internal assistant) calls one endpoint, and the request body is standardized as memoryId + message.

Agent orchestration

The system prompt fixes the agent's role, language, and behavior; a stable memoryId enables multi-turn follow-ups and clarification.

Tagged tool routes

listRecentOrders, queryOrderDetail, cancelOrder — each tool declares a clear description, explicit parameter declarations, and returns deterministic JSON.

Unified response contract

Keep the response schema stable — success, memoryId, responseText, toolData, timestamp — so UI rendering, logs, and audit all read the same shape.

Real calls before you call it done

Run 10-20 real user prompts through the entrypoint with curl or Postman, and track success rate, clarification rate, and error rate. One real call against the demo service:

curl -X POST "http://localhost:19095/api/ai/agent/chat" \
  -H "Content-Type: application/json" \
  -d '{"memoryId":"demo-order-session","message":"查询订单 MOCK-1001 的状态"}'

Every client reads the same stable contract — responseText for people, toolData for machines:

{
  "success": true,
  "memoryId": "demo-order-session",
  "responseText": "Order MOCK-1001 is shipped.",
  "toolData": { "orderId": "MOCK-1001", "status": "SHIPPED" },
  "timestamp": "2026-08-11T12:00:00Z"
}

A 7-day delivery plan

  1. Day 1-2: stand up the single listener endpoint and fix the request contract as memoryId + message.
  2. Day 3-4: implement three high-value tools — list, detail, and one action such as cancel — with consistent parameter and error semantics.
  3. Day 5-6: verify multi-turn memory by reusing one memoryId across follow-ups, then normalize responses so the UI and logs share one protocol and failures stay traceable.
  4. Day 7: run the 10-20-prompt acceptance pass and record success rate, clarification rate, and error rate before demoing.

When the loop misbehaves

If the agent never calls a tool, check that tags align between the agent and its tools, strengthen tool descriptions so they are distinguishable, and verify the parameter declarations are complete.

If multi-turn context is lost, reuse the same memoryId, confirm memory is enabled, and tune the memory turn limit. Scaling past MVP means adding tools route by route from one proven domain — not rewriting the architecture. A low budget is not the blocker; the lack of a standard orchestration pattern is.

AI Agent + Tools guideAiAgentDemoSrv sample