Back to Blog
BlogBlog

Your AI Agent Found the Right Data. What If It Uses the Wrong Context?

AI agents need the right context to make reliable decisions. Learn why context engineering matters for Microsoft Foundry agents.

Softree TeamPublished: October 8, 20265 min read
ai-agent

Introduction

An AI agent can retrieve the correct document and still produce the wrong answer. The problem is not always retrieval. The agent may also need the right instructions, conversation history, user information, tool outputs, permissions, business rules, and task-specific data at the right time.

This is why context engineering is becoming important for Microsoft Foundry agents. Microsoft Foundry Agent Service combines models with instructions, tools, conversations, and other capabilities that allow agents to perform more than simple question answering.

Quick Answer: What Is Context Engineering?

Context engineering is the deliberate design and control of the information an AI agent receives before and during execution.

This context can include:

  • System instructions
  • User requests
  • Conversation history
  • Retrieved enterprise knowledge
  • Memory
  • Tool outputs
  • Business rules
  • User permissions
  • Task-specific information

The goal is not to give an agent as much information as possible. The goal is to provide the right information, in the right form, at the right time.

Why Is Context More Important for AI Agents?

Traditional applications generally follow predefined logic. An AI agent has more flexibility to interpret requests, retrieve information, select tools, and determine what action to take.

That flexibility also introduces a new problem: the same data can produce different outcomes depending on the context surrounding it.

For example, an agent might retrieve an older troubleshooting document that correctly describes an application issue. If the user's application has since been upgraded, that document may no longer apply.

The data was technically relevant, but the context was wrong.

For enterprise agents, context therefore needs to account for the user's request, current conversation, business rules, available tools, permissions, and the most relevant enterprise information.

What Context Does a Microsoft Foundry Agent Need?

A production agent may need several context layers working together.

Instructions define how the agent should behave, what priorities it should follow, and which boundaries it must respect.

Conversation history provides continuity across multiple turns so the agent understands what has already been discussed.

RAG and enterprise knowledge provide grounding information from business documents and other sources. Microsoft Foundry supports retrieval capabilities that can provide relevant information to an agent.

Memory can provide persistent context when an application needs continuity across sessions. Microsoft Foundry Agent Service currently provides managed long-term memory capabilities as a preview feature.

Tools and APIs give agents access to business actions and live information.

Identity and access controls determine what information and actions are available to a particular user or agent.

Evaluation and observability help teams identify where context-related failures occur.

How Does Context Engineering Work?

A production agent starts with the user's request and assembles the context required to complete the task.

Consider an enterprise IT support agent investigating an application outage. Instead of relying only on a retrieved troubleshooting document, the agent may need to consider:

  • The current application version
  • Recent conversation history
  • Approved troubleshooting documentation
  • Customer or application information
  • Source metadata
  • Tool results
  • User permissions

The agent can then evaluate these sources together before generating its recommendation.

This approach is especially important when information can conflict. A newer application version may make an older troubleshooting article inappropriate even though the article is highly relevant to the original issue.

RAG Is Not the Same as Context Engineering

RAG is an important part of an agent's context, but it is only one part.

RAG helps an agent retrieve relevant information from enterprise data. Context engineering determines how that information is combined with instructions, conversation history, memory, user information, tools, permissions, and business rules.

Microsoft Foundry's file search capabilities can retrieve relevant information from uploaded enterprise documents and use that information to ground agent responses.

The important distinction is simple:

RAG answers: “What information should I retrieve?”

Context engineering asks: “What information should the agent consider, prioritize, and use for this task?”

When Should You Use Microsoft Foundry Agents?

Microsoft Foundry agents are particularly useful when an application needs enterprise knowledge, multiple tools or APIs, stateful conversations, user-specific context, security controls, or RAG combined with instructions and tools.

A simpler model-based application may be more appropriate when the application only needs a single response, has little enterprise context, follows a deterministic workflow, and does not require tools, memory, or retrieval.

The key question is not whether an agent can be used. It is whether context materially affects the decision the system needs to make.

How to Build Production-Ready Agent Context

Context should be treated as an architecture concern rather than only a prompt-writing exercise.

Start by defining exactly what information the agent needs for each task. Separate stable instructions from dynamic information. Keep retrieved context focused instead of passing large amounts of irrelevant content.

Memory should have a clear purpose and scope. Tool descriptions should explain what each tool does and when it should be used. Identity and least-privilege controls should be applied before sensitive information becomes part of the agent's working context.

Teams should also test conflicting, outdated, and incomplete information rather than evaluating only successful responses.

Microsoft Foundry Agent Service provides managed runtime capabilities for agents, conversations, tools, identity, security, and observability, which can support production agent architectures.

Real-World Technical Example

Imagine an enterprise IT support agent receives the request:

“The application is showing an authentication error. How should I fix it?”

The agent retrieves an approved troubleshooting document recommending a specific configuration change. However, the document applies to version 4 of the application while the employee is running version 5.

A context-aware agent should consider the application version, conversation history, document metadata, user permissions, and available diagnostic tools before recommending the change.

The goal is not simply to retrieve a relevant document. The goal is to determine whether that document is relevant to this user, this application version, and this specific situation.

Production Checklist

Before deploying a Microsoft Foundry agent, verify:

  • The required context is clearly defined.
  • Stable instructions are separated from dynamic information.
  • Conversation history is controlled.
  • Retrieved information is relevant and focused.
  • Memory has a defined purpose and scope.
  • Tool capabilities are clearly described.
  • Least-privilege access is applied.
  • Conflicting and outdated information is tested.
  • Context quality is evaluated separately from final answers.
  • Retrieval and tool behavior are monitored.
  • Important instructions and knowledge sources are versioned.

Key Takeaway

Finding the right data does not guarantee the right decision.

For Microsoft Foundry agents, context determines how retrieved information is interpreted and used. Instructions, conversation history, memory, RAG, tools, identity, and business rules all contribute to the agent's decision-making context.

Build AI Agents With the Right Context

Softree Technology helps businesses design and build production-ready AI solutions across Microsoft Azure, AWS, and enterprise systems, covering agent architecture, RAG, integrations, data, identity, security, governance, and deployment. Softree_Microsoft_Foundry_Agent…

Ready to build AI agents that use the right context—not just more data?
https://www.softreetechnology.com/

FAQ

Frequently Asked Questions.

Question Answer:

Softree Technology is an offshore technology and engineering partner providing Agentic AI, Generative AI, AI automation, Microsoft Fabric, Power Platform, data engineering, cloud engineering, software development, and digital transformation services. We help technology companies, consulting firms, Microsoft partners, SaaS companies, AI companies, and other organizations extend their engineering capabilities and build modern digital solutions.

Question Answer:

Yes. Softree Technology provides offshore software development and engineering services from India. We work as an extension of client engineering and delivery teams, providing dedicated developers, specialized technology teams, and project-based engineering capabilities. Our expertise spans Agentic AI, Microsoft technologies, data and analytics, cloud, automation, and modern application development.

Build faster with a reliable offshore engineering partner.

Partner with Softree to accelerate product delivery, modernize enterprise systems, and scale with confidence.

Person wearing a white hooded jacket and virtual reality headset against a shimmering abstract background.

What we offer

Enterprise Integration
Cloud Architecture
AI & Automation
Microsoft Solutions
Offshore Engineering

Offices

  • Bengaluru

    11th Floor, Prestige Tech Park, Platina 2 · Outer Ring Rd, Kadubeesanahalli · Bengaluru, Karnataka 560087, India

  • Cuttack

    PLOT B6-1628, SECTOR-10, CDA · Cuttack, Odisha 753014 · India

  • San Francisco

    San Francisco, CA 94108 · United States

Got a question, challenge, or idea?

Fill out the form or pick a time on our scheduler.

30-min discovery call

Same Calendly as our booking page · instant invite