You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: dotnet/src/Microsoft.Agents.AI.Abstractions/AIAgent.cs
+34Lines changed: 34 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -20,6 +20,19 @@ namespace Microsoft.Agents.AI;
20
20
/// <see cref="AIAgent"/> serves as the foundational class for implementing AI agents that can participate in conversations
21
21
/// and process user requests. An agent instance may participate in multiple concurrent conversations, and each conversation
22
22
/// may involve multiple agents working together.
23
+
/// <para>
24
+
/// <strong>Security considerations:</strong> An <see cref="AIAgent"/> orchestrates data flow across trust boundaries —
25
+
/// messages are sent to external AI services, context providers, chat history stores, and function tools. Agent Framework
26
+
/// passes messages through as-is without validation or sanitization. Developers must be aware that:
27
+
/// <list type="bullet">
28
+
/// <item><description>User-supplied messages may contain prompt injection attempts designed to manipulate LLM behavior.</description></item>
29
+
/// <item><description>LLM responses should be treated as untrusted output — they may contain hallucinations, malicious payloads (e.g., scripts, SQL),
30
+
/// or content influenced by indirect prompt injection. Always validate and sanitize LLM output before rendering in HTML, executing as code,
31
+
/// or using in database queries.</description></item>
32
+
/// <item><description>Messages with different roles carry different trust levels: <c>system</c> messages have the highest trust and must be developer-controlled;
33
+
/// <c>user</c>, <c>assistant</c>, and <c>tool</c> messages should be treated as untrusted.</description></item>
34
+
/// </list>
35
+
/// </para>
23
36
/// </remarks>
24
37
[DebuggerDisplay("{DebuggerDisplay,nq}")]
25
38
publicabstractpartialclassAIAgent
@@ -165,6 +178,11 @@ public ValueTask<AgentSession> CreateSessionAsync(CancellationToken cancellation
165
178
/// This method enables saving conversation sessions to persistent storage,
166
179
/// allowing conversations to resume across application restarts or be migrated between
167
180
/// different agent instances. Use <see cref="DeserializeSessionAsync"/> to restore the session.
@@ -195,6 +208,11 @@ protected virtual async ValueTask<AIContext> InvokingCoreAsync(InvokingContext c
195
208
/// In contrast with <see cref="InvokingCoreAsync"/>, this method only returns additional context to be merged with the input,
196
209
/// while <see cref="InvokingCoreAsync"/> is responsible for returning the full merged <see cref="AIContext"/> for the invocation.
197
210
/// </para>
211
+
/// <para>
212
+
/// <strong>Security consideration:</strong> Any messages, tools, or instructions returned by this method will be merged into the
213
+
/// AI request context. If data is retrieved from external or untrusted sources, implementers should validate and sanitize it
214
+
/// to prevent indirect prompt injection attacks.
215
+
/// </para>
198
216
/// </remarks>
199
217
/// <param name="context">Contains the request context including the caller provided messages that will be used by the agent for this invocation.</param>
200
218
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to monitor for cancellation requests. The default is <see cref="CancellationToken.None"/>.</param>
Copy file name to clipboardExpand all lines: dotnet/src/Microsoft.Agents.AI.Abstractions/AgentSession.cs
+14Lines changed: 14 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -42,6 +42,15 @@ namespace Microsoft.Agents.AI;
42
42
/// <see cref="JsonElement"/> and the <see cref="AIAgent.DeserializeSessionAsync(JsonElement, JsonSerializerOptions?, System.Threading.CancellationToken)"/> method
/// and other potentially sensitive data including PII. Developers should:
48
+
/// <list type="bullet">
49
+
/// <item><description>Treat serialized session data as sensitive and store it securely with appropriate access controls and encryption at rest.</description></item>
50
+
/// <item><description>Treat restoring a session from an untrusted source as equivalent to accepting untrusted input. A compromised storage backend
51
+
/// could alter message roles to escalate trust, or inject adversarial content that influences LLM behavior.</description></item>
/// Messages are returned in chronological order to maintain proper conversation flow and context for the agent.
160
168
/// The oldest messages appear first in the collection, followed by more recent messages.
161
169
/// </para>
170
+
/// <para>
171
+
/// <strong>Security consideration:</strong> Messages loaded from storage should be treated with the same caution as user-supplied
172
+
/// messages. A compromised storage backend could alter message roles to escalate trust (e.g., changing <c>user</c> messages to
173
+
/// <c>system</c> messages) or inject adversarial content that influences LLM behavior.
174
+
/// </para>
162
175
/// </remarks>
163
176
/// <param name="context">Contains the request context including the caller provided messages that will be used by the agent for this invocation.</param>
164
177
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to monitor for cancellation requests. The default is <see cref="CancellationToken.None"/>.</param>
Copy file name to clipboardExpand all lines: dotnet/src/Microsoft.Agents.AI.Mem0/Mem0Provider.cs
+22Lines changed: 22 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -13,16 +13,38 @@
13
13
14
14
namespaceMicrosoft.Agents.AI.Mem0;
15
15
16
+
#pragma warning disable IDE0001// Simplify Names - Microsoft.Extensions.Logging.LogLevel.Trace doesn't get found in net472 when removing the namespace.
16
17
/// <summary>
17
18
/// Provides a Mem0 backed <see cref="MessageAIContextProvider"/> that persists conversation messages as memories
18
19
/// and retrieves related memories to augment the agent invocation context.
19
20
/// </summary>
20
21
/// <remarks>
22
+
/// <para>
21
23
/// The provider stores user, assistant and system messages as Mem0 memories and retrieves relevant memories
22
24
/// for new invocations using a semantic search endpoint. Retrieved memories are injected as user messages
23
25
/// to the model, prefixed by a configurable context prompt.
26
+
/// </para>
27
+
/// <para>
28
+
/// <strong>Security considerations:</strong>
29
+
/// <list type="bullet">
30
+
/// <item><description><strong>External service trust:</strong> This provider communicates with an external Mem0 service over HTTP.
31
+
/// Agent Framework does not manage authentication, encryption, or connection details for this service — these are the responsibility
32
+
/// of the <see cref="HttpClient"/> configuration. Ensure the HTTP client is configured with appropriate authentication
33
+
/// and uses HTTPS to protect data in transit.</description></item>
34
+
/// <item><description><strong>PII and sensitive data:</strong> Conversation messages (including user inputs, LLM responses, and system
35
+
/// instructions) are sent to the external Mem0 service for storage. These messages may contain PII or sensitive information.
36
+
/// Ensure the Mem0 service is configured with appropriate data retention policies and access controls.</description></item>
37
+
/// <item><description><strong>Indirect prompt injection:</strong> Memories retrieved from the Mem0 service are injected into the LLM
38
+
/// context as user messages. If the memory store is compromised, adversarial content could influence LLM behavior. The data
39
+
/// returned from the service is accepted as-is without validation or sanitization.</description></item>
40
+
/// <item><description><strong>Trace logging:</strong> When <see cref="Microsoft.Extensions.Logging.LogLevel.Trace"/> is enabled,
41
+
/// full memory content (including search queries and results) may be logged. This data may contain PII and should not be enabled
42
+
/// in production environments.</description></item>
0 commit comments