Agents, impersonation and identity propagation¶
An agent request can involve different identities:
The authenticated caller: the user identity that makes the technical query to the Agent. For example:
The user making a query to an Agent directly in its Test Chat or Prompt Studio
The user whose Personal API key is used to make an API query to the Agent
The backend user of a web app that makes an API query to the Agent
The user running a Python recipe making such a query
The Run As user of a Scenario (or a recipe said scenario runs) making such a query
The agent’s execution identity (also called “runner user”): the identity used to run the agent and access its underlying LLM connection and tools. By default, this is the authenticated caller above. Alternatively, the Run as configuration can specify a fixed DSS user.
The end-user caller: the identity of the end user logged into DSS and asking the agent a question, for example through Conversational interfaces. Compatible tools can use this user’s identity and credentials to access resources, such as per-user credentials on the connection of a dataset used by a Dataset Lookup tool.
These identities may or may not differ, depending on the situation. For example, Conversational interfaces query an agent using their backend identity, which may be different than the end user using those interfaces.
Identity used by a tool¶
By default, a tool called by an agent uses the agent’s identity. The following tools let you choose the identity used to access resources:
The identity settings distinguish between:
Tool runner: the identity executing the tool, the agent’s identity in the case of usage within an agent (as opposed to using the tool by direct API call).
End-user caller: the end-user caller making the query to the Agent.
The identity used to perform the tool’s action follows the tool’s configuration:
Tool setting |
Valid caller ticket |
No caller ticket |
|---|---|---|
User directly running the tool |
Tool runner |
Tool runner |
End-user caller (through tool context) |
End user |
Error: missing ticket |
End-user caller if available, else user running the tool |
End user |
Tool runner |
Both end-user modes reject invalid or expired tickets. The “if available” mode uses the tool runner only when no ticket is supplied.
End-user impersonation applies the user’s permissions and the connection’s security settings. For connections with per-user credentials, the end user must configure those credentials and complete any required OAuth authorization.
Note
The identity used to access a resource determines which credentials and access policies apply. For example, a SQL connection configured with per-user credentials can use the end user’s database credentials, allowing database policies to restrict the rows returned.
Knowledge Bank Search uses a separate mechanism: document-level security filters documents using callerSecurityTokens supplied in the request context. It does not derive these tokens from the caller ticket.
Providing the end-user identity¶
The end-user identity is provided to the LLM Mesh or agent through a ticket, which is proof of authentication for that end user. This enables compatible tools to use that user’s identity when configured to do so. It does not change the agent’s execution identity.
Passing a dkuCallerTicket in context¶
A client application can pass a ticket directly in the dkuCallerTicket key of the Additional Request Context:
{"context": {"dkuCallerTicket": "<ticket for the end user>"}}
Keep tickets in the additional request context, outside prompts, tool descriptions and custom logs. Share them only with agents and tools you trust to act as the end user.
See External applications for how to obtain a ticket from outside DSS.
Conversational interfaces¶
Prompt Studio and the native agent test chat automatically supply a caller ticket for the querying user. These tickets expire when the request ends.
In Agent Hub and Agent Chat, Include DSS caller ticket in the agent context enables ticket forwarding. Requests contain an end-user ticket only when this option is enabled.
For example, an Agent Hub backend queries an agent using a technical identity / user account. To let Dataset Lookup access data as Alice, enable Include DSS caller ticket in the agent context and configure the tool to use End-user caller (through tool context). If the connection uses per-user credentials, Alice must have configured her credentials.
Custom webapps¶
A custom webapp obtains the end user’s ticket from the browser request headers. In this Flask example, client is the webapp’s DSS API client and completion is its prepared completion query:
from flask import request
ticket = client.get_ticket_from_browser_headers(dict(request.headers))
completion.with_context({"dkuCallerTicket": ticket})
The webapp requires permission to obtain a ticket for the browser user, and the user must be logged into DSS. See Impersonation with webapps for examples.
External applications¶
get_ticket() returns a ticket for the API client’s authenticated identity. To obtain an end-user ticket, use a client authenticated with that user’s personal API key:
import dataikuapi
end_user_client = dataikuapi.DSSClient(DSS_URL, END_USER_PERSONAL_API_KEY)
ticket = end_user_client.get_ticket()
completion.with_context({"dkuCallerTicket": ticket})
The application can query the agent with separate credentials while tools use the end-user ticket. A login supplied as request metadata does not authenticate the end user.
Forwarding context through other agents¶
Forward the additional request context on downstream calls that need to obtain this end-user ticket. Enable Forward context when calling another agent or LLM, and pass the context explicitly in Code Agents and custom tools.
Using the ticket in a Python tool¶
TicketImpersonationContext applies the ticket’s identity to DSS API calls. Use it inside a custom Python tool’s invoke method:
import dataiku
from dataiku.core.intercom import TicketImpersonationContext
ticket = (input.get("context") or {}).get("dkuCallerTicket")
if not ticket:
raise ValueError("An end-user caller ticket is required")
with TicketImpersonationContext(ticket):
client = dataiku.api_client()
auth_info = client.get_auth_info() # end user's auth info
# Do other calls as the end user
Create the client and perform impersonated operations inside the impersonation context. The above example rejects calls without a ticket.
For a complete tool implementation, see Impersonate end-user identity in a custom agent tool.
Identity in logs and usage reporting¶
dkuOnBehalfOf is a key in the Additional Request Context, alongside dkuCallerTicket. It identifies the user to whom a request is attributed. It does not authenticate that user or change the identity used to access resources. This user does not need a DSS account, for example when using the Slack or Microsoft Teams integration.
Agent Hub supplies this value automatically. The Caller identity settings can also populate it from the authenticated caller.
When the corresponding logging is enabled:
LLM audit events record
dkuOnBehalfOfasonBehalfOf, alongside authentication information.Compute resource usage records carry this attribution in the
DKUOnBehalfOfallocation tag.Agent interaction logs record authentication information separately from the
userfield. That field usesdkuOnBehalfOfwhen supplied, otherwise the authentication identifier.
For cost quotas, the User (runner) dimension uses the execution identity, while End user uses dkuOnBehalfOf. End user or runner user uses dkuOnBehalfOf when supplied, otherwise the runner user.
Note that supplying dkuCallerTicket does not automatically populate dkuOnBehalfOf.
Advanced: setting an agent’s execution identity¶
An agent’s Execution identity settings determine which DSS user executes the agent and accesses its underlying LLM connection. Specify a Run as fixed identity, or leave the default to use the authenticated caller’s identity.
This setting applies to Visual Agents, Structured Visual Agents, Code Agents and Plugin Agents. Users with permission to edit the agent can select themselves or clear their own setting. Selecting another user requires administrator privileges.
Caller identity controls how Dataiku supplies dkuCallerTicket and dkuOnBehalfOf automatically from the authenticated caller. Caller-context generation applies only when Run as specifies a fixed DSS user. To derive missing values or override supplied values, the authenticated caller must be associated with a DSS user.
Setting |
Behavior |
|---|---|
Do not propagate caller context |
Keep the supplied context unchanged (default). |
Populate caller context when absent |
Keep supplied values, derive missing values from the authenticated caller. |
Always use the authenticated caller |
Replace supplied values with values derived from the authenticated caller. |
This lets an agent run under a fixed identity while supported tools access resources as the caller.
For webapp calls, the authenticated caller is the execution identity set in the webapp backend settings, which can differ from the actual end user. To preserve the end user’s identity, supply their ticket and use either Do not propagate caller context or Populate caller context when absent.