Prompt engineering for a mobile app AI assistant

The AI assistant in the app answers inaccurately or goes off-topic — the client loses user trust. We build prompt engineering end-to-end: behavior rules, response scenarios, and a prompt library. Answer accuracy increases, and the number of support requests decreases.

Development and support of all types of mobile applications:

Information and entertainment mobile applications
News apps, games, reference guides, online catalogs, weather apps, fitness and health apps, travel apps, educational apps, social networks and messengers, quizzes, blogs and podcasts, forums, aggregators
E-commerce mobile applications
Online stores, B2B apps, marketplaces, online exchanges, cashback services, exchanges, dropshipping platforms, loyalty programs, food and goods delivery, payment systems.
Business process management mobile applications
CRM systems, ERP systems, project management, sales team tools, financial management, production management, logistics and delivery management, HR management, data monitoring systems
Electronic services mobile applications
Classified ads platforms, online schools, online cinemas, electronic service platforms, cashback platforms, video hosting, thematic portals, online booking and scheduling platforms, online trading platforms

These are just some of the types of mobile applications we work with, and each of them may have its own specific features and functionality, tailored to the specific needs and goals of the client.

Our competencies:

Frequently Asked Questions

Latest works

  • Development of a mobile application for FEEDME
    Development of a mobile application for FEEDME
    971
  • Development of a mobile application for XOOMER
    Development of a mobile application for XOOMER
    869
  • Development of a mobile application for RHL
    Development of a mobile application for RHL
    1289
  • Development of a mobile application for ZIPPY
    Development of a mobile application for ZIPPY
    1143
  • Development of a mobile application for Affhome
    Development of a mobile application for Affhome
    1076
  • Development of a mobile application for the FLAVORS company
    Development of a mobile application for the FLAVORS company
    677

Prompt engineering for an AI assistant: where the logic of responses breaks down

Prompt engineering for an AI assistant in an app begins not with polished wording, but with analyzing exactly where the logic of responses breaks down.

The assistant looks functional in a demo and falls apart in real scenarios: the user asks a follow-up question two messages later, changes the topic, writes with typos, or mixes two requests into one.

Response quality drops not because of the model, but because behavior rules, role boundaries, and handling of dialogue context are described in fragments.

The first class of failures is irrelevant answers. The assistant either drifts into general reasoning instead of the app's data, or invents facts that don't exist in the system.

The cause is usually that the instructions don't set source priority: what to take from the user profile, what from the catalog, and what is forbidden to make up.

The second class is loss of dialogue context: the assistant forgets what was being discussed, asks again for something already stated, and loses selected filters when moving between screens.

What matters here is not the length of the history, but which entities are extracted from it and carried into the next request.

The third class is unstable behavior under growing load. The same question produces different answers depending on the length of the history, the order of messages, and how many requests arrived in parallel.

The assistant starts "sliding" into a different tone, cutting off responses, or ignoring constraints. This is a consequence of the prompt being assembled from disconnected pieces without a unified structure and without stability testing.

We break down how this is addressed: how the structure of instructions is designed, how dialogue context is retained, and how the assistant's behavior is tested against scenarios rather than a single lucky example.

What a well-built prompt engineering framework delivers

Prompt engineering is not about "tweaking the wording" — it is a managed layer between the model and the product. A prompt defines the assistant's role, knowledge boundaries, response format, and escalation rules to a human operator.

When this layer is built systematically, the assistant's behavior becomes predictable: it responds consistently to identical requests, and for non-standard ones it does not make things up but instead asks for clarification or hands off to a human.

What we measure and what changes

The share of relevant answers grows through strict anchoring to the knowledge base and explicit "what not to do" instructions.

Response speed drops when the prompt does not force the model to reason out loud where a short fact is needed, and the response format is predefined.

Robustness to requests is tested with a set of adversarial scenarios: typos, mixed languages, off-topic questions, attempts to extract internal instructions. We run these sets on every prompt change so that an improvement in one scenario does not break the others.

What this looks like in practice

We version prompts like code, store reference dialogues, and compare the assistant's metrics before and after changes.

Dialogue quality is assessed not "by eye" but by the share of requests resolved without an operator and by the number of clarifying questions per scenario. This loop allows the assistant's behavior to be changed in a targeted way — without rebuilding the application.

Our approach relies on OpenAI and other models as an interchangeable layer: the assistant's logic lives in prompts and rules, not in a specific vendor. This reduces the risk that switching models will wipe out the accumulated dialogue quality.

Approaches to Prompt Construction: Comparing Modes

The choice of approach to organizing prompts determines how predictably the assistant conducts a dialogue and how quickly the cost of calling the model grows.

A rigid template with a fixed role instruction delivers a stable tone and response format, but breaks on the very first non-standard user request.

Dynamic context assembly and dialogue memory remove this limitation, but require control over history length and priorities between blocks.

In practice, the modes do not compete but combine: the base layer sets the role and boundaries, and the context of the current session is assembled on top of it. Below is a comparison of when each approach is appropriate and where its limitations begin.

Approach When it fits Limitations
Rigid template with a role instruction Stable scenarios: help, order status, typical operations Does not handle non-standard wording; any deviation from the scenario results in a refusal or hallucination
Template with variable slots A single scenario with variable data: substituting a name, order, city The number of branches grows, and template maintenance becomes more complex with each new variable
Dynamic context assembly The assistant answers based on application and external source data Relevance control is needed: extra blocks blur the instruction and increase latency
Chain of prompts with dialogue memory Multi-step tasks: checkout, selection, step-by-step diagnostics History grows, requiring summarization and explicit rules on what to forget

What the choice of mode solves

Rigid templates win where repeatability matters: the same request yields an identical response, and the assistant's behavior is easy to cover with checks.

Dynamic prompts and dialogue memory are needed when the user pursues a task in several steps and expects the assistant to retain the context of previous turns.

Where the approaches break down

The main limitations are context overflow and instruction conflict: the more blocks are added to the prompt, the higher the chance that the model will ignore some of them.

That is why we fix priorities between layers, limit history depth, and move recurring data into a structured form rather than free text.

How we structure work with prompts: stages

Prompt engineering for an assistant is not about finding "lucky phrasings" but an engineering cycle: analyze existing scenarios, design the structure of instructions, validate on live dialogues, and hand over to the team the guidelines by which the system can be developed without us. Below is how the process works.

  1. Scenario audit. We collect real user requests, label where the assistant answers incorrectly or drifts off topic, and record typical dialogue branches. The output is a scenario map with priorities: what is critical for the business and what is a rare case.
  2. Prompt design. We formalize the assistant's role, the boundaries of acceptable answers, tone, and escalation rules to a human operator. The structure is built in blocks — instruction, context, examples — so that edits in one block do not break the others.
  3. Assistant setup. We connect prompts to the application's data and external sources, and define behavior for incomplete or contradictory requests. Separately, we specify what the assistant must not do.
  4. Dialogue testing. We run scenarios on a set of real and edge-case requests, comparing answers against the reference. Every prompt edit goes through re-validation — regressions are caught before release.
  5. Quality measurement. We calculate the share of correct answers, the frequency of escalations, and returns to topic. The metrics show where the assistant is still "drifting" and set the next iteration cycle.
  6. Handover of guidelines. We give the team a document with the logic of the prompts, the rules for changes, and a validation checklist. From then on, edits are made according to it, without contacting us for every change.

This cycle repeats as the product grows: new application features mean new scenarios, and prompts are updated along with them rather than remaining at the level of the first version.

Artifacts: prompt library and assistant behavior rules

A prompt library is not a set of texts in a shared document, but a versioned catalog: each scenario lives in a separate file with a description of its purpose, input data, and the expected behavior of the assistant.

Edits go through review and are included in the application release together with the code, so the assistant's behavior is reproducible from build to build, rather than depending on who last touched the wording.

Behavior rules describe not only "what to answer" but also "what not to do": topic boundaries, handling of personal data, mandatory clarifications before an action, and the priority between instructions.

Dialogue branch diagrams capture the forks — greeting, clarification, confirmation, refusal, escalation to an operator — indicating the condition under which the assistant takes one branch or another.

A separate block is exception handling: empty or contradictory input, a request outside the scope of responsibility, an unavailable service, retries.

For each failure class, a scenario and a fallback response are defined so that the assistant does not "hang" or invent data.

The client receives:

  • a structured prompt library with versioning and change history;
  • assistant behavior rules: topic boundaries, data handling, instruction priority;
  • dialogue branch diagrams with transition conditions and escalation points;
  • an exception handling policy by failure class;
  • assistant documentation: scenario purpose, input data, expected behavior;
  • a set of test dialogues for verifying changes before release;
  • instructions for making edits — who changes prompts, how, and through which review.

The documentation is updated together with the library: if a scenario changes, the outdated description does not remain hanging separately. Describe your task — we will come back with an estimate and a plan for the composition of artifacts for your product.

Case study: how the assistant's answer accuracy grew

The client is a grocery delivery service with an assistant inside its mobile app.

The assistant answered questions about orders, product composition, and delivery times, but in a third of cases it produced irrelevant answers: it mixed up categories, suggested items that were out of stock, and ignored delivery address restrictions.

Users abandoned the dialogue at the second message, and support received the same questions manually.

We started with an audit: we analyzed a log of several thousand dialogues, labeled where the answer went off track, and divided the errors into three classes — incorrect substitution of order data, loss of context between messages, and going beyond the role.

Then we rewrote the system prompt: we fixed the role and boundaries, added a mandatory verification of order facts before answering, and described the behavior when data is insufficient — a clarifying question instead of a guess.

Separately, we assembled a set of reference dialogues and ran every new version of the prompt through it.

Metrics before and after

Metric Before After
Share of relevant answers 68% 94%
Dialogues completed to the end 41% 73%
Support requests on the order topic baseline level −38%
Return to the assistant in the next session 22% 47%

The growth in retention here is a consequence, not a separate task: once the assistant stopped making mistakes on simple questions, users began solving through it what they previously went to look up manually. An important point — the prompt is not static.

We built in a regression run on the reference dialogues before every release and a rule: any change to the model or the data substitution logic must pass validation on this set. Without this, accuracy rolls back within a couple of updates.

Case study from our team's practice — details under NDA, figures are based on internal measurements over a comparable period.

How does prompt engineering differ from fine-tuning a model?

Prompt engineering and fine-tuning a model solve the same problem — getting the assistant to respond in the right tone, format, and within acceptable topics — but they work at different levels.

Prompt engineering changes the instruction: the system message, role description, dialogue examples, refusal rules, and response format. The model stays the same; only what is fed to it as input changes.

Fine-tuning changes the model's weights themselves on a prepared set of examples — behavior is locked in at the parameter level.

The difference shows up in the nature of the task. If you need to set the style, response structure, limit the subject matter, or add a couple dozen examples of "correct" replies — prompts are enough, and edits are made in minutes without rebuilding and redeploying.

Fine-tuning is needed when there are too many rules, they conflict with each other, and the model still "drifts" on rare scenarios: then examples are collected by the thousands, and training transfers the patterns into the weights.

The limitations of the approaches are mirror images of each other. Prompts are not free in terms of context: the more instructions and examples, the longer the request and the higher the latency and cost per call.

Fine-tuning removes part of this load, but requires a labeled dataset, a training cycle, and re-running checks with every update — which means longer time to release and higher support costs.

In practice, the choice almost always goes from prompts to fine-tuning, not the other way around.

First you squeeze the maximum out of instructions and examples, measure which scenarios show a drop in quality, and only if the drop is persistent and confirmed by metrics do you move to fine-tuning. The reverse order means training on a poorly understood task and extra iterations.

There is also a hybrid mode: the base model is fine-tuned on a narrow domain, while specific behavior rules, tone, and format remain in the prompts — this makes it easier to change the product without retraining.

We start with prompts and quality metrics, and make the decision about fine-tuning based on data, not intuition.

Common technical concerns

Prompt engineering for an assistant is not a "set of lucky phrases" but a managed layer between the model and the product. Below are the engineering questions most often raised during a technical review, and how we address them.

How is the stability of the assistant's responses ensured when the model is updated?

Prompts are versioned alongside the code rather than edited "live" in the interface. Before rollout, the new model branch is run against a set of reference scenarios: typical queries, edge-case phrasings, attempts to steer the assistant off course.

If the share of correct responses falls below the threshold, the release is blocked and the prompt is refined. This way, a model update does not become a surprise for users.

What about prompt security and leak protection?

The system instruction is stored on the server and never goes to the client application — only the user's query lives in the application. Secrets and access keys are moved to a secure vault; they are not present in the prompt text.

Separately, we close off attempts to extract the instruction or bypass restrictions: suspicious queries are filtered, and responses are checked for prohibited content.

How does the solution scale as load grows?

The prompt layer is separated from the application logic, so it withstands growth in the number of users without being rewritten. Queries are cached where the response does not depend on context, and heavy scenarios are moved to a queue. As the audience grows, capacity is added rather than the assistant's logic being rebuilt.

How is quality controlled after launch?

We keep a log of queries and responses, label failed cases, and turn them into new checks. Metrics — the share of correct responses, the number of refusals, response time — are visible on a dashboard. This allows us to make targeted prompt fixes rather than rewriting the assistant entirely.

Describe your task — we will come back with an estimate and a plan for the prompt layer for your product.

Let's discuss your task and come back with a plan

To propose a structure for the work, we need to understand the current state of the assistant: which scenarios it already handles, where it responds inconsistently, and which requests get routed to human operators.

Describe the task in your own words — that's enough for us to come back with an estimate and an implementation plan. Prompt engineering doesn't start with writing instructions; it starts with analyzing real dialogues and the boundaries the assistant must not cross.

Next, we'll propose a structure: which scenarios to handle first, where strict constraints on response format are needed, and where clarifying questions to the user are appropriate.

We'll also discuss separately how the assistant should behave with incomplete data, conflicting instructions, and requests outside its area of responsibility.

What the implementation plan includes:

  • analysis of current scenarios and typical user requests;
  • a map of the assistant's roles: what it does on its own, what it clarifies, and what it hands off to a human;
  • a structure of instructions for each scenario with response format rules;
  • a set of test dialogues and acceptance criteria for each scenario;
  • a rollout sequence: from a single scenario to full coverage without stopping the application;
  • a process for editing instructions after launch and quality control checkpoints;
  • an estimate of work by stages with clear timelines and areas of responsibility.

On our side, we'll provide recommendations on which scenarios should be automated first and which should remain with human operators for now — this reduces the risk of a negative experience at the start.

Describe the task and the assistant's current scenarios: we'll come back with an estimate of the work and a plan for the next steps.