Skip to main content
An AgentRuntimePrincipal limits which permissioned capabilities Harnest makes available during one invocation. Create it in trusted application code after authenticating the caller or deciding which service identity a job should use.
The generated id is an opaque runtime identity. Your application remains the source of user, tenant, role, and policy decisions.
Do not derive permissions from model output or an untrusted request field. Authenticate at your application or gateway boundary, then construct the principal in trusted code.

Mark permissioned capabilities

Server and client-hosted tools accept one permission identifier:
An MCP client can require a permission for every remote tool and add requirements to individual tools:
mcp/catalog.py
permission= applies to every tool from that client. A matching tool_permissions entry is an additional requirement. Permission identifiers start with a letter and can contain letters, numbers, ., _, :, or -.

Invoke with a principal

Pass the principal through a trusted custom HTTP endpoint:
You can also pass agent_principal= to an in-process AgentSession.invoke(...) or AgentSession.stream(...) call. Harnest removes unavailable capabilities from Harnest-owned model tool surfaces and checks the permission again at execution. Treat the execution check as defense in depth. The downstream service must still authorize the actual operation.

Understand omission and propagation

Queued state contains only permission identifiers. It does not serialize the principal ID, authentication claims, or credentials. A scheduled Task can construct and pass an explicit service principal in trusted task code when it needs declared capabilities.

Managed and advanced modes

In advanced mode, Harnest enforces the principal for Harnest-decorated server tools, client-hosted tools, configured MCP clients, local agent invocation, and queued Task propagation when those operations cross Harnest runtime boundaries. Harnest does not rewrite a native graph, inspect every framework plugin, or wrap tools that you wire directly into your own agent graph. Those user-owned paths remain your responsibility and can bypass runtime-principal projection. Enforce equivalent policy in the native graph or downstream gateway when you need complete coverage.
The principal is private runtime state rather than a property on harnest.context. Tools and extensions declare required permissions; they do not read or make policy decisions from the active principal.