Guide

Context Engineering and Memory for Business AI Agents

Reliable agents need the right evidence at the right moment. Context engineering selects what enters the current decision; memory preserves selected information beyond it.

Context engineering designs the agent's working view

An AI agent cannot consider every policy, record, tool and prior conversation at once. Context engineering decides which instructions, evidence, tool descriptions, case history and workflow state the model receives for the present step. The goal is not maximum information. The goal is enough relevant, current and authorised information to make the next decision well.

Context engineering is broader than prompt engineering. A carefully written instruction can still fail when the agent sees stale policy, the wrong customer, an ambiguous tool or an irrelevant conversation history.

Separate five sources of context

Stable instructions define purpose, limits and response requirements. Retrieved knowledge supplies policy, product or procedural evidence. Live case data supplies the current customer, asset, order or event. Tool definitions state what actions are available and how to call them. Workflow state records completed steps, approvals and outstanding obligations.

Each source changes at a different rate and has a different owner. Combining them in one long prompt makes version control and error investigation difficult. The implementation should assemble the working context from governed sources for each step.

Memory is information retained beyond the immediate decision

Short-term memory maintains continuity inside a session or case. Durable workflow state records facts such as a task identifier, approval and completion status. Long-term memory retains selected information across sessions, such as a stable customer preference or a recurring operating fact. Organisational knowledge belongs in a governed knowledge source rather than being inferred repeatedly from conversation.

Memory is therefore not a transcript archive. The design decides what is worth retaining, how it is verified, who may retrieve it, how conflicts are resolved and when it expires.

Do not confuse memory with truth

A remembered statement may have been incomplete, mistaken or true only at one time. The agent should retrieve authoritative current data for matters such as account status, room assignment, inventory or entitlement. Memory may help locate the right source or preserve a user preference, but it should not silently replace the system of record.

Attach provenance, time and scope to material memory. Provide correction and deletion routes. Test what happens when a newer fact contradicts the stored item.

Control context growth

Long-running work produces messages, tool results, documents and intermediate plans. Passing everything back to the model increases cost and can bury important instructions. Use structured state for facts the workflow must preserve. Summarise older conversation only when the summary retains the decisions, evidence and unresolved obligations. Retrieve documents when needed instead of carrying them through every step.

Compaction and retrieval are design choices that need evaluation. A shorter context is useful only if the omitted detail does not change the outcome.

A hospitality example with four different memories

A hotel guest-service agent receives a request about a room fault. The current stay and room come from the property system. The open engineering task and its status belong to workflow state. The hotel's compensation policy is retrieved as governed knowledge. A durable preference such as communication language may be retained with the guest's consent and a correction route.

The agent should not treat a previous room number as memory worth reusing, and it should not assume an acknowledged engineering task is complete. When the guest moves rooms, current system state must override the earlier conversation. This separation prevents personalisation from corrupting operations.

Evaluate the assembled context

Test retrieval relevance, source freshness, identity resolution, instruction priority, tool selection and memory boundaries separately. Then test the whole case with conflicting sources, missing records, malicious text inside a document and a stale memory. Examine the trace to see what entered the model at each step.

The business measure is not how much the agent remembered. It is whether the agent used appropriate evidence, protected information and completed the case without creating correction or rework.

What Marketways delivers

Marketways defines the context map, source hierarchy, retrieval rules, workflow state model, memory policy and evaluation cases. We connect those technical choices to the business entities and decisions they represent. The result gives process, data and engineering owners a shared description of what the agent knows, what it may remember and when it must return to an authoritative source.

Continue through the implementation practice

References

  1. Anthropic, effective context engineering for AI agents
  2. Microsoft Foundry, memory in Agent Service
  3. LangGraph persistence
  4. Amazon Bedrock AgentCore memory observability