Retrieve the signed-in customer’s approved account context, then use it to answer a support-plan question. This guide uses the same protected service contract across the five warehouse manuals; the selected manual owns its provider access and deployment.
Before you begin
- A test application with a real sign-in and a developer-owned runtime proxy. The backend maps the authenticated login to the authorized tenant/customer and keeps runtime credentials/session keys server-side.
- One completed warehouse setup: Snowflake, BigQuery, Redshift, Fabric Warehouse or Databricks SQL. Its service, Secret, API tool and provided lookup-token variable must pass the manual’s standalone check.
- Two distinct test customers, a data owner’s approved field definitions and a freshness policy. The example view contains plan, support tier, open-case count and source refresh time.
Retrieve and use the context
Authorize the current customer
Have the application backend authenticate the login and resolve its tenant/customer mapping. Use trustedContextTurn on every forwarded launch, turn and supported resume; it issues a short-lived signed lookup token and discards browser variable/state/identity overrides. Stop private lookup when the mapping is missing. A typed email, runtime user ID or initial launch variable alone is not authentication.
Attach the current lookup
Studio
Open Agent → Global tools → Read authorized customer context. Keep service_token provided by the restricted Secret and lookup_token provided by warehouse_lookup_token. Set Trigger to reading the signed-in customer’s support plan or case count when they ask. A saved request in Tools alone is not an agent attachment.
Code
Follow the selected provider manual’s API-tool creation and attachment commands. Retain API_TOOL_ID; its attachment must use the two returned input IDs and provided defaults. Compile the test Draft and resolve unresolvedReferences. The proxy must provide a fresh token for the same login on every turn; keep credentials on the backend.
Answer the actual customer question
Send “What support does my plan include?” through the authenticated application. Inspect the current tool invocation and result before answering. Require ok: true, found: true, the intended customer ID and an allowed source_updated_at. Use only the approved plan/tier/case fields and the data owner’s policy; a tier label alone does not define service entitlements.
Handle missing, stale or failed context
For found: false, rejected authorization or unavailable/stale data, explain that account context is unavailable and continue with general help. Do not reuse a previous customer’s result or infer that an absent row means no account. fetched_at is the request time; only source_updated_at describes upstream freshness.
Verify the customer boundary
- Customer A and Customer B each receive only their approved context and an answer consistent with it.
- A later-turn foreign ID/token/state override cannot change the server-authorized mapping. Test the proxy and the actual tool result, not only a model’s refusal.
- Expired/tampered tokens, duplicate rows, stale source data and revoked provider access produce the general-help path without private data.
- An unfinished provider query does not produce an account-specific answer. The service deadline does not prove that remote compute stopped.
A current warehouse read does not ingest Knowledge. For reusable reference content, follow Importing data sources and verify its separate selection, completion and refresh contract.