Izrada pozadinskih sustava: umjetna inteligencija mora savladati vašu poslovnu logiku
AI does not truly understand your business because it can summarize a policy document or answer questions about a codebase. It begins to become useful when it can operate safely inside the decisions that make your company distinct: who can approve a refund, when inventory may be reserved, how a customer becomes eligible for a service, and which exceptions require human review.
That is why backend design matters more than ever. An agent can be impressive in a demo while still being dangerously vague about the rules that govern real work. The difference between a helpful AI system and an expensive source of operational risk is often the quality of the backend contracts it is allowed to use.
Business logic is the product, not an implementation detail
In many systems, business rules have accumulated across controllers, database triggers, scheduled jobs, spreadsheets, and the institutional memory of a few experienced people. Humans can sometimes navigate that ambiguity through judgment. AI cannot be expected to do so reliably.
An AI model is good at interpreting intent, handling unstructured language, and proposing a next action. It is not a dependable replacement for deterministic rules. If a discount must never be combined with a contract price, that constraint should live in an authoritative service, not in an instruction such as “remember not to stack discounts.”
Think of the model as a capable operator at the edge of your system. It can translate a customer request into a structured action, ask clarifying questions, and explain an outcome. Your backend must remain the source of truth for validation, authorization, calculations, state transitions, and audit records.
Give agents narrow, meaningful capabilities
The most effective AI integrations do not expose a database and hope the model behaves. They provide a small set of well-designed tools that correspond to real business operations. Each tool should do one meaningful thing and return a clear result.
For example, an order-support agent may need tools to look up an order, identify eligible remedies, create a return request, and draft a customer-facing explanation. It does not need unrestricted access to update arbitrary order fields.
- Use business verbs. Prefer
create_return_requestover a genericupdate_order. - Accept structured inputs. Require identifiers, reasons, quantities, and other fields your backend can validate.
- Return actionable outcomes. Include status, machine-readable reason codes, and safe details for the user.
- Separate preview from commitment. Let an agent calculate eligibility before it performs an irreversible action.
- Make permissions explicit. The user, service account, and agent context should all participate in authorization.
This design also improves ordinary software development. A tool fit for an agent is usually a better application boundary for a web client, support workflow, or future integration because it expresses intent rather than leaking storage details.
Turn vague requests into controlled workflows
Consider the request, “Can you cancel my subscription and make sure I am not charged again?” A language model can recognize the intention, but several business questions remain. Is the requester the account owner? Is the subscription already in a non-cancellable renewal period? Should access end immediately or at the end of the billing cycle? Is a refund possible?
A safe workflow gives the model a sequence of constrained choices. It may first retrieve the subscription and cancellation policy. It can then explain the available options, request confirmation where needed, and call a cancellation command only after the backend has checked the current state.
{
"subscription_id": "sub_123",
"requested_end": "period_end",
"confirmed_by_customer": true
}
The backend should not trust the model’s interpretation of eligibility. It should derive the allowed options from current records and policy. If the request cannot proceed, return a reason the agent can communicate accurately, such as a missing authorization check or an already-cancelled subscription.
This division of labor is powerful: the model manages conversation and ambiguity; the backend manages truth and consequences.
Design for uncertainty, retries, and partial failure
AI-driven flows are not single, perfectly ordered requests. A model may retry a tool call after a timeout. A user may change their mind mid-conversation. A downstream payment provider may accept a request while your application loses the response. If the backend is not designed for these realities, an apparently harmless agent can produce duplicate charges, duplicate tickets, or contradictory messages.
Use idempotency for state-changing operations. A stable request key lets the server recognize that two equivalent submissions represent one intended action. Persist the final outcome so a retry can return the original result instead of repeating the work.
Also distinguish between a failure to start work and uncertainty about whether work completed. A timeout after sending a refund request is not permission to send another refund request. The correct recovery path is usually to query the authoritative status, reconcile the operation, and then tell the agent what is known.
Make state visible
Long-running actions need durable states such as pending, processing, completed, and failed. Avoid a simple success-or-error response when the real world is asynchronous. An agent can then say, “Your request is being processed,” without pretending that an external operation has already finished.
Clear state models are especially important when a human must intervene. The agent should be able to create a review case with the relevant context, tell the user what will happen next, and avoid making promises that only an approver can keep.
Build explanations into the contract
When an agent cannot complete an action, the failure response should help it recover. A bare 403 or “invalid request” pushes the model toward guessing. A structured response can indicate whether it needs another confirmation, a different account identifier, a human approval, or simply a later retry.
Do not expose sensitive policy logic or internal notes merely to make responses more descriptive. Use reason codes for machines and carefully selected messages for people. The agent can translate those messages into natural language, but it should not be asked to invent the policy rationale.
Auditability matters as well. Record what action was requested, which principal authorized it, the tool inputs that were accepted, the resulting state change, and any approval involved. This is not only for incident response. It makes it possible to improve prompts, tools, and policies with evidence rather than intuition.
Test the system at the boundary where AI operates
Traditional unit tests remain essential, but AI integration adds another layer. Test tool contracts and workflow behavior with valid, incomplete, conflicting, stale, and unauthorized inputs. Verify that the same mutation request is safe to retry. Verify that a model cannot bypass validation by choosing a surprising field value or calling operations in an unexpected order.
Then test conversations as scenarios, not as magical proofs of intelligence. The question is not whether a model produces elegant prose. The question is whether every path leads to a correct backend outcome, a useful request for clarification, or a safe escalation.
Make AI earn broader authority
The best path to capable agents is progressive trust. Begin with read-only assistance, recommendations, and drafts. Add reversible actions with confirmation. Introduce higher-impact operations only when the surrounding controls, observability, and operational ownership are ready.
AI will change how people reach your software, but it should not change the standard your software meets. Build business logic as explicit, testable capabilities; let models reason over those capabilities; and keep consequential decisions anchored in systems that can validate, explain, and recover. That is how an AI assistant becomes genuinely useful without becoming an uncontrolled participant in the business.