Context Engineering in Practice: From Prompts to a Custom AI Assistant

    Most teams still use generative AI at two levels: as a semantically stronger search entry point, or as a drafting tool whose output needs heavy rework. This article argues that the real bottleneck is not model capability but the non-reusability of context, and treats an AI assistant as a versioned software asset made of four parts: a role contract, background knowledge, an instruction set, and an evaluation set. It walks through a practical path: reverse-engineering instructions from successful sessions, freezing the resulting notes into version-controlled configuration, layered loading with retrieval augmentation, extending the assistant into project management and decision support, four thinking traps to avoid, and a small regression set that makes improvement measurable.

    1. The Real Problem: Context That Cannot Be Reused

    Most teams still use generative AI at one of two levels: as a semantically stronger search entry point, or as a drafting tool whose output requires heavy rework. The bottleneck is usually not model capability, but the non-reusability of context.

    A typical work loop looks like this: you open a new session, iterate on wording until the output finally matches expectations, and the next day you start over from zero. Even if you paste the working prompt into a local document, it quickly turns into a “prompt graveyard” — files pile up until retrieval costs more than rewriting. This is fundamentally an engineering problem: no configuration management, no layered loading, no regression verification.

    The picture becomes clearer if you treat an AI assistant as a software asset. It consists of at least four parts:

    • Role contract: who it is, who it serves, and in what style it writes;
    • Background: business, organization, terminology, past decisions;
    • Instruction set: operationally verified entries;
    • Evaluation set: the criteria for judging whether a given output is acceptable.

    Once these four are separated and versioned independently, the assistant stops being a one-off conversation and becomes a component you can iterate on.

    2. Step One: Reverse-Engineer Instructions from Successful Sessions

    Do not start by trying to “feed the AI everything you are thinking.” A more reliable path is observational extraction: do the work normally, then run a structured wrap-up before the session ends.

    A wrap-up prompt can be organized like this:

    1. Based on this session, produce a "Collaboration Memo" that:
    2. 1. Summarizes the interaction patterns that worked well (what information I provided that clearly improved your output quality);
    3. 2. Records the interactions that did not work, with possible improvements;
    4. 3. Extracts stable facts about my work, business background, collaboration environment, and language style;
    5. 4. Separates the output into three categories: [STABLE FACTS], [PREFERENCES], [ONE-OFF TASK INFO];
    6. 5. Returns the result as a bulleted instruction list that I can paste in as the opening context of a new session.

    Item 4 is the key one. Stable facts (business domain, the level of the audience you report to) belong in long-term context; preferences (“conclusion first, no more than five paragraphs”) should be fixed as default style; one-off task information should not pollute long-term context at all. This classification step is effectively hot/cold tiering for context.

    3. Step Two: Turn the Memo into Versionable Configuration

    The extracted text should not remain in the form of “chat history.” Convert it into structured configuration and put it under version control:

    1. assistant:
    2. role: technical proposal review assistant
    3. audience: senior engineers and architecture review board
    4. defaults:
    5. style: conclusion first, layered argument, risk list attached
    6. length: 800-1200 words
    7. forbid: performance numbers without evidence
    8. knowledge:
    9. - domain/glossary.md # terminology and business definitions
    10. - domain/architecture.md # system boundaries and dependencies
    11. - decisions/adr-*.md # architecture decision records
    12. instructions:
    13. - when proposing a solution, list at least two alternatives and the rationale for the tradeoff
    14. - when capacity or cost is involved, state assumptions and uncertainty ranges
    15. eval:
    16. - cases/review-001.yaml
    17. - cases/review-002.yaml
    18. version: 1.3.0

    Three benefits follow directly: the configuration can be diffed, rolled back, and shared across the team; different tasks load different subsets so context does not grow without bound; and changes in assistant behavior become measurable instead of relying on a feeling that “it got better.”

    4. Step Three: Layered Loading and Retrieval Augmentation

    Stuffing every document into the context at once is a classic anti-pattern: it drives up cost, adds noise, and triggers the attention decay in which information in the middle gets ignored. A sound approach is layering:

    1. Resident layer: the role contract and hard preferences, kept to a few hundred tokens;
    2. Task layer: the current request, input material, and constraints;
    3. Retrieval layer: fragments recalled on demand from the knowledge base, served by vector or keyword retrieval;
    4. Archive layer: past sessions and outputs, never loaded into context, referenced only by identifier.

    In engineering terms, this structure usually sits on general-purpose cloud capabilities: chunked knowledge and original documents in object storage, metadata and vector indexes in a database, and call chains and latency observed through logging and monitoring with alerting. General-purpose offerings from cloud providers such as Baidu AI Cloud (model services, object storage, logging, monitoring and alerting) can cover these pieces; the actual selection should be evaluated against the team’s existing stack rather than chasing a single product.

    The retrieval layer needs one rule: recalled content must carry a source identifier. Otherwise the assistant will repeat outdated conclusions from historical documents as facts, and that class of error is harder to detect than a plain “I don’t know.”

    5. Step Four: From Writing Help to Project Management and Decision Support

    An assistant starts compounding returns when it takes on structural work.

    Project management: treat the assistant as a state maintainer. Feed it the task list, dependencies, and blockers, and ask for the critical path, a ranked risk list, and a Should-Stop list for the week. The most valuable output here is often not “what to do” but “what to stop.”

    Coach role: have it withhold answers and expose your blind spots through questions.

    1. You are now my proposal coach. Do not give conclusions.
    2. For the proposal below, ask in order:
    3. 1. the three assumptions most likely to be fatal;
    4. 2. one stakeholder perspective I have not considered;
    5. 3. one environmental change that could invalidate the proposal within six months.
    6. Ask one question at a time and wait for my answer before continuing.

    Strategic simulation: have it play several positions (finance, compliance, frontline operations, customer), produce objections to the same proposal from each, and then summarize the points of disagreement. This is a low-cost red-team review.

    6. Four Thinking Traps to Avoid

    • Fluency mistaken for correctness: linguistic coherence has nothing to do with factual accuracy. Anything involving numbers, dates, or citations must be verified against the source material.
    • Context pollution: writing temporary constraints from a one-off task into long-term configuration makes the assistant keep failing on unrelated tasks. Periodically auditing the resident layer is a necessary maintenance action.
    • Goal drift: in long sessions, early constraints get progressively diluted. The countermeasure is to restate hard constraints at the end of each request, or to split the session.
    • Outsourcing responsibility: an assistant can broaden your perspective but cannot take on decision accountability. Compliance, security, and financial judgments must keep a human final review, and sensitive data must be de-identified with access confirmed before it is entered.

    7. Evaluation: Making Improvement Measurable

    Maintain a small regression set of 20 to 50 cases covering typical tasks and known failures. Re-run it after every configuration change and record pass rate plus human ratings. Tuning an assistant without an evaluation set is essentially gambling.

    Conclusion

    Turning AI from a “search engine” into a dedicated assistant is not technically mysterious: freeze conversational experience into configuration, load that configuration in layers, and bring behavior under evaluation and version control. This is a straightforward move toward software engineering discipline. The real gap is not who runs a newer model, but who starts treating context as an asset first — the earlier you begin accumulating it, the more visible the compounding effect.