Skip to main content
All Python modules · Import and compatibility guidance Use from harnest import context for capabilities bound to the current managed invocation. Access to a capability does not extend its lifetime beyond that invocation.

Invocation capabilities

These attributes are resolved at runtime rather than stored as module globals. Use the linked types for their methods; accessing a managed property during import or outside its required runtime raises an availability error. Identity properties such as context.user_id, context.session_id, and context.invocation_id read from the active AgentContext. See Agent runtime principals for authorization and Tasks for task-initiated agent calls.

Memory operations

Session operations

Exports

AgentContext

Stable invocation identity and its explicitly exported resources. Obtain this object from the owning Harnest API; its constructor includes runtime bindings. Fields (— means no declared default):

AgentContext.resource

Return one named capability without exposing the whole registry.

AgentContext.is_root

Report whether this scope represents the compiled root agent.

AgentContinuationUnsupportedError

A local invocation reached a continuation its caller cannot service.

AgentInvocationTimeout

An in-process agent invocation exceeded its configured deadline.

AgentInvocationUnavailableError

No compiled runtime is bound to the current authored task.

AgentPendingResponse

A persisted external wait that can be resumed by the owning runtime.
Fields (— means no declared default):

AgentPendingResponse.as_dict

Expose only provider-neutral durable continuation metadata.

AgentResponse

Framework-neutral result returned by an in-process invocation.
Fields (— means no declared default):

AgentResponse.as_dict

Return strict JSON without stringifying unsupported output objects.

AgentSession

One persisted session owned by a local in-process runtime identity. Obtain this object from the owning Harnest API; its constructor includes runtime bindings. Fields (— means no declared default):

AgentSession.invoke

Run one non-streaming turn through the complete runtime pipeline.

AgentSession.stream

Stream portable events and a final response with cancellation cleanup.

AgentSessionNotFoundError

An identity-scoped local session does not exist.

AgentStreamItem

One portable runtime event or the validated terminal response.
Fields (— means no declared default):

AgentStreamItem.as_dict

Serialize a stable local envelope without importing HTTP contracts.

ContextRegistration

Metadata declaring the name and order of one context provider.
Fields (— means no declared default):

ContextResourceError

Raised when an invocation does not contain a requested resource.

ContextUnavailableError

Raised when agent context is accessed outside a Harnest invocation.

LocalAgentRuntime

Invoke a final compiled runtime driver without an HTTP round trip.

LocalAgentRuntime.user_id

Return the session owner selected by the local caller.

LocalAgentRuntime.create_session

Create one persisted session under the configured local identity.

LocalAgentRuntime.open_session

Open an existing session without revealing another owner’s records.

MemoryContext

Access explicit memories across sessions within one application/user scope.

MemoryContext.namespace

Select a logical collection without changing application/user ownership.

MemoryContext.put

Deliberately save or replace a memory, recording invocation provenance.

MemoryContext.get

Read a scoped key without adding it to model context.

MemoryContext.list

List a bounded page of explicit memories across this user’s sessions.
Search literal text on explicit request, without model calls.

MemoryContext.delete

Explicitly forget a memory and its provider index references.

ScopedAssets

Named asset capabilities restricted to one authenticated invocation. Obtain this object from the owning Harnest API; its constructor includes runtime bindings.

ScopedAssets.call

Select one named store without exposing its backing implementation.

ScopedAssets.save

Persist streamed bytes and return a reference carrying store routing.

ScopedAssets.stat

Return safe metadata for an owned asset or fail closed.

ScopedAssets.open

Stream owned bytes without exposing the backing storage object.

ScopedAssets.get

Read a bounded asset for APIs that require an in-memory payload.

ScopedAssets.delete

Delete an owned asset without revealing another scope’s content.

ScopedAssets.url

Ask an explicitly URL-capable storage for a fresh temporary URL.

SessionContext

Provide JSON-safe access to the current session’s application-data lane. Obtain this object from the owning Harnest API; its constructor includes runtime bindings.

SessionContext.get

Return a detached value without exposing mutable store-owned state.

SessionContext.set

Persist one value without projecting it into framework model state.

SessionContext.update

Persist a bounded mapping in one lease-owned write.

SessionContext.delete

Delete one value and report whether the current namespace contained it.

SessionContext.namespace

Return a nested view so teams and plugins can avoid key collisions.

SessionDataError

Raised when application session data violates its scoped contract.

StorageContext

Resolve custom storage without exposing sessions or checkpoints.

StorageContext.call

Return one named custom resource for concise authored access.

StorageContext.resource

Resolve a custom store while keeping the registry non-enumerable.

activate_agent_scope

Narrow managed identity to the framework component currently executing.

current

Return the active managed invocation context.

derive_agent_context

Create a child view that shares only its parent’s revocable capabilities.

provider

Declare one invocation-scoped resource on the public context namespace.

resource

Resolve one explicitly published invocation resource.

SandboxHandle

Access this facade through context.sandboxes["name"]; its implementation type is not a public import. A revocable agent-and-invocation-bound execution capability.

SandboxHandle.execute

Execute tool-authored code with immutable provider policy and identity.

SandboxHandle.aexecute

Keep blocking providers off the event loop and revoke cancelled work.