Skip to content

API Reference parrot.semantic.context

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.semantic.context

View source

Trusted semantic identity and scoped request-context binding.

Alias PermissionContext

Re-exported from parrot.auth.PermissionContext.

Alias SemanticAccessError

Re-exported from parrot.semantic.errors.SemanticAccessError.

Class SemanticRequestIdentity

Host-authenticated identity for retained semantic results.

Fields:

Field Type Default Description
ctx PermissionContext
channel Literal['http', 'agent', 'mcp-local']
agent_id str
session_id str

Method SemanticRequestIdentity.snapshot_context

Copy trusted request context so later caller mutations cannot alter it.

snapshot_context() -> 'SemanticRequestIdentity'

Returns: 'SemanticRequestIdentity'

Alias SemanticResultError

Re-exported from parrot.semantic.errors.SemanticResultError.

Alias TraceContext

Re-exported from parrot.core.events.lifecycle.TraceContext.

Function bind_semantic_context

Bind copied context and identity; restore all tokens in finally.

bind_semantic_context(ctx: PermissionContext, *, identity: SemanticRequestIdentity | None = None) -> AsyncIterator[None]

Parameter Type Default Description
ctx PermissionContext Host-authenticated permission context for this call.
identity SemanticRequestIdentity | None None Optional complete retention identity; it must describe the same subject as ctx.

Returns: AsyncIterator[None]

Raises:

  • SemanticAccessError — If ctx is missing or disagrees with identity.

Function current_identity

Return the complete retention identity, if bound.

current_identity() -> SemanticRequestIdentity | None

Returns: SemanticRequestIdentity | None — The bound identity, or None for context-only or unbound calls.

Function current_pctx

Return the current trusted permission context.

current_pctx() -> PermissionContext | None

Returns: PermissionContext | None — The bound permission context, or None outside a binding scope.

Function require_identity

Deny retention/handoff when no complete trusted scope is bound.

require_identity() -> SemanticRequestIdentity

Returns: SemanticRequestIdentity — The bound trusted identity.

Raises:

  • SemanticResultError — If no complete identity is bound.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally