Why this matters
Without situational awareness, every conversation starts cold. The user has to explain where they are and what they’re looking at before the agent can help. With it, the agent already knows. The conversation feels continuous with the user’s activity, not disconnected from it. This is especially valuable for:- Product pages. A retail customer embeds the agent on their store. When a user clicks “Ask about this product”, the agent immediately knows which product they mean, its price, its availability.
- Internal dashboards. An HR platform embeds the agent on a performance review page. The user asks “what does this report tell me about my team?” and the agent knows which report, which team, which time period.
- Priming questions. When a specific button or link triggers the chat, the host page can tell the agent why the user opened it, so the agent can lead with the right response instead of a generic greeting.
- Personalization. The host page can pass the user’s role, department, or timezone so the agent tailors its language and recommendations.
When to use situational awareness
Use it when the agent needs to understand the user’s context to give a better response. SA puts information into the LLM’s reasoning: the agent reads it and uses it to inform what it says and which tools it calls. SA is the right choice when:- The user’s current page, selection, or activity matters to the conversation
- You want the agent to reference specific context without the user having to type it
- The data is small (under 10,000 characters) and descriptive
- A tool needs exact data verbatim, like a JSON blob, a document, or a file. Pass-through parameters handle that case.
- The data is sensitive and shouldn’t be visible to the LLM (SA goes into the system prompt)
Setting situational awareness
Two ways to set SA: an HTML attribute for static initial values, and a JavaScript method for dynamic updates.HTML attribute
Set initial context directly on the element:situational-awareness attribute value is a JSON-encoded string. Write the JSON object inline (escaping quotes as needed by your HTML), with each key as a context label and each value as a string. The SDK parses the string on read. Both situational-awareness (kebab-case) and situationalAwareness (camelCase) are accepted. For dynamic updates after the page loads, use the JavaScript method instead. It takes a real object, not a string.
JavaScript method
Set or update SA dynamically:agent.setSituationalAwareness() is sync. Call it once mindset.init() has completed and the element has fired mindset:agent-idle. See § When the element is ready to call. To clear SA, pass an empty object:
Dynamic updates
SA is designed for pages where context changes as the user navigates. CallsetSituationalAwareness() whenever the context changes:
Size limits
The SDK enforces a hard character limit on SA payloads. The LLM reads the entire SA payload on every message, so this prevents runaway token costs.| Limit | Threshold | Behavior |
|---|---|---|
| Default | 10,000 characters | Exceeding this throws an error. A warning is logged above 9,000 characters. |
| Extended | 20,000 characters | Opt-in via extendedSituationalAwareness: true in mindset.init(). Warning above 18,000 characters. |
setSituationalAwareness() exceeds the active limit, it throws an error and the SA is not updated.
Passing structured data
SA values are typically short strings, but you can pass structured data when the use case requires it. Stringify the value:Triggering the agent programmatically
SA tells the agent what’s happening. To trigger the agent to act on that context without the user typing, useagent.sendMessage():
sendMessage(text) appends a visible user message. sendMessage(text, { silent: true }) appends a hidden message: the agent responds, but the trigger message is not shown in the chat UI. This is useful for buttons on the host page that should trigger agent behavior without cluttering the conversation.
What the LLM sees
SA entries are wrapped in structural tags in the system prompt, clearly demarcating external context from the agent’s own instructions:<situational-awareness> tags help the LLM treat the content as data rather than directives, providing a structural boundary between your context and the agent’s configuration.
The key names you choose become the labels the LLM reads. Use descriptive, human-readable keys. The LLM treats these as factual context about the user’s current state.
Scenarios
Page context
The most common use case. The host page tells the agent what the user is looking at:Priming the conversation
Provide context about why the user opened the chat:Passing data for tool reasoning
When a tool (MCP or page) needs a data payload, the LLM needs to understand the data to write good instructions. SA lets the LLM see a summary of the data while Pass-through Parameters handle the actual data transfer to the tool. The setters are the natural fit because the data typically changes as the user navigates:User identity context
Provide user-specific context so the agent can personalize responses:Guidelines for key design
Do:- Use descriptive, human-readable key names (
product_name, notpn) - Keep values concise. The LLM reads every character.
- Update SA when the user’s context changes (tab switches, page navigation)
- Use SA for context the LLM should reason about
- Exceed 10,000 characters total (or 20,000 with extended SA)
- Put large data blobs in SA. Use pass-through parameters for exact data transfer to tools.
- Include sensitive data you don’t want the LLM to see
- Pass raw page content or unsanitized user-generated text (see best practices below)
Best practice: curate what you send
Situational awareness is designed for structured, application-controlled context: product IDs, page titles, category names, user roles. Values you construct from your own application logic. The agent gets the most value from concise, relevant context rather than large blocks of raw content. Because SA content becomes part of the LLM’s system prompt, it can influence how the agent responds. This is the point of the feature, but it means you should be intentional about what goes in:- Pass specific values, not raw page content. A product name and price is more useful to the agent (and cheaper in tokens) than a scraped DOM. The agent doesn’t need HTML tags; it needs structured facts.
- Be mindful of user-generated content. If your page displays reviews, comments, or form inputs from end users, avoid passing that content directly into SA. User-originated text could unintentionally shift the agent’s behavior. If you need to include it, sanitize first: strip markup, truncate to a reasonable length, validate the content.
- Review your SA values during development. If your integration dynamically constructs SA from page state, log the payload during testing. Confirm that the values reaching the agent are what you expect and contain only the context you intend.
Design properties
Transient per request. SA is scoped to the message it’s sent with. It doesn’t become part of the stored thread and isn’t replayed on subsequent turns. This prevents stale context from accumulating, so the agent never thinks the user is on a page they’ve already left. Always current, never stale. Each message stands on its own. If a message doesn’t include SA, the agent proceeds naturally using only the thread history. Size-enforced. The SDK enforces hard limits to prevent runaway token costs. Default 10,000 characters; opt into 20,000 withextendedSituationalAwareness: true in init(). If you routinely send large SA payloads, keep your agent configuration lean (shorter personality, fewer policy rules) so the total system prompt stays within a comfortable budget.
Generic pass-through. The platform doesn’t interpret or filter keys. The meaning of keys is a contract between the host page (who sends them) and the LLM (who interprets them).
Combining with pass-through parameters
Situational Awareness and Pass-through Parameters are complementary, not alternatives:| Situational Awareness | Pass-through Parameters | |
|---|---|---|
| Who sees it | The LLM (in the system prompt) | The tool’s handler (MCP server or page tool), in the tool-call arguments |
| Purpose | Give the LLM context to reason about | Give tools exact data without LLM mediation |
| Data fidelity | Approximate (LLM interprets it) | Exact (byte-for-byte transfer) |
| Token cost | Uses prompt tokens (LLM reads it every message) | Zero LLM tokens (stripped from the schema the LLM sees) |
| When to use | LLM needs to understand the data | Tool needs the data verbatim |
Quick reference
| Concept | Description |
|---|---|
situational-awareness attribute | HTML attribute on <mindset-agent> to set initial context |
agent.setSituationalAwareness(obj) | JavaScript method to set or update context dynamically (preferred for dynamic updates) |
agent.sendMessage(text, options?) | Trigger the agent programmatically. Pair with SA to act on context. |
| Key-value format | {"key": "value"} JSON object |
| System prompt section | <situational-awareness>...</situational-awareness> |
| Update timing | Takes effect on the next message sent |
| Persistence | Transient per request, never saved to thread history |
| Clearing | agent.setSituationalAwareness({}) to remove all context |
| Default size limit | 10,000 characters (warning at 9,000, error above 10,000) |
| Extended size limit | 20,000 characters (opt-in via extendedSituationalAwareness: true in init()) |
Related
Data channels overview
How situational awareness fits alongside the other host-page-to-agent channels.
Page tools
Let the agent take actions on the host page.
Pass-through parameters
Inject exact data into tool calls without the LLM copying it.
Agent Session Parameters
Identity headers for MCP servers.
Element methods
Full element method surface.
<mindset-agent> element
The element reference including the situational-awareness attribute.