Skip to main content
All Python modules · Import and compatibility guidance

HTTP agent principal grants

@lifecycle.http.agent_principal registers one sync or async function that receives a ConnectionContext and an AuthPrincipal. Return an AgentRuntimePrincipal to grant permissions or None to deny the invocation. See Grant permissions on built-in routes.

Hook control flow

Exports

CoverageLevel

Describe how completely Harnest governs one runtime boundary.

DROP_EVENT

EvalCaptureOptions

Authored capture settings; None defers to the environment, then defaults.
Fields (— means no declared default):

Finish

Complete an intercepting lifecycle stage without calling later work.
Fields (— means no declared default):

LifecycleContext

Portable invocation context shared by listeners for one execution.
Fields (— means no declared default):

LifecycleContext.next

Continue normally or pass a replacement to the next interceptor.

LifecycleContext.finish

Return a final value without advancing to later execution.

LifecycleCoverage

Stable report of lifecycle boundaries Harnest can actually guarantee.
Fields (— means no declared default):

LifecycleCoverage.stage

Return one declared stage without exposing implementation state.

LifecycleCoverage.report

Return an immutable JSON-compatible diagnostics report.

LifecycleCoverage.with_overrides

Record adapter-observed limits without changing mode defaults.

LifecycleListener

One discovered callback with a deterministic source identity.
Fields (— means no declared default):

LifecycleListener.identity

Return the stable identity used to order and deduplicate listeners.

LifecycleRegistration

Metadata attached by one lifecycle decorator.
Fields (— means no declared default):

ModelCallRequest

Portable model input that a listener may replace or short-circuit.
Fields (— means no declared default):

ModelCallResponse

Portable visible model output.
Fields (— means no declared default):

ModelLifecycleContext

Stable provider-neutral facts associated with one model call.
Fields (— means no declared default):

ModelLifecycleContext.next

Continue normally or pass a replacement to the next interceptor.

ModelLifecycleContext.finish

Return a final value without advancing to later execution.

ModelMessage

One provider-independent text message in a model call.
Fields (— means no declared default):

Next

Continue a lifecycle chain, optionally with a replacement value.
Fields (— means no declared default):

Next.replaces

Report whether the next stage should receive a replacement value.

TransitionContext

Give typed lifecycle contexts one consistent control-flow vocabulary.

TransitionContext.next

Continue normally or pass a replacement to the next interceptor.

TransitionContext.finish

Return a final value without advancing to later execution.

adk_plugin

Register a native ADK plugin factory at the lifecycle boundary.

agent

Name invocation hooks by their agent lifecycle responsibility.

agent.before

Preserve authored hook signatures while attaching lifecycle metadata.

agent.after

Preserve authored hook signatures while attaching lifecycle metadata.

agent.on_event

Preserve authored hook signatures while attaching lifecycle metadata.

agent.on_error

Preserve authored hook signatures while attaching lifecycle metadata.

authenticate

Preserve authored hook signatures while attaching lifecycle metadata.

coverage

Build conservative defaults and apply adapter-observed coverage limits.

credential_provider

Preserve authored hook signatures while attaching lifecycle metadata.

eval_capture_options

Return capture options attached by @lifecycle.evals.capture.

evals

Production eval improvement hooks, valid only in lifecycle/evals_improvement.py.

evals.capture

Select finished invocations for structure-only or team-redacted capture. store names a @lifecycle.storage.custom provider implementing harnest.eval_capture.CaptureStore. sample_rate additionally captures that fraction of invocations the rule rejects. Content is omitted unless @lifecycle.evals.redact is registered. That hook takes and returns one CaptureRecord; any other return value drops the capture. Harnest does not detect personal data.

evals.redact

Preserve authored hook signatures while attaching lifecycle metadata.

http

Group server middleware hooks under the HTTP lifecycle boundary.

http.scope

Preserve authored hook signatures while attaching lifecycle metadata.

http.before

Preserve authored hook signatures while attaching lifecycle metadata.

http.after

Preserve authored hook signatures while attaching lifecycle metadata.

http.on_error

Preserve authored hook signatures while attaching lifecycle metadata.

http.agent_principal

Preserve authored hook signatures while attaching lifecycle metadata.

http_routes

Preserve authored hook signatures while attaching lifecycle metadata.

langgraph_middleware

Register a native LangGraph middleware factory at the lifecycle boundary.

lifecycle_coverage

Build conservative defaults and apply adapter-observed coverage limits.

mcp

Group managed remote-tool hooks separately from transport ownership.

mcp.before

Preserve authored hook signatures while attaching lifecycle metadata.

mcp.after

Preserve authored hook signatures while attaching lifecycle metadata.

mcp.on_error

Preserve authored hook signatures while attaching lifecycle metadata.

model

Group provider-neutral model hooks under one authoring namespace.

model.before

Preserve authored hook signatures while attaching lifecycle metadata.

model.after

Preserve authored hook signatures while attaching lifecycle metadata.

model.on_error

Preserve authored hook signatures while attaching lifecycle metadata.

output_policy

Preserve authored hook signatures while attaching lifecycle metadata.

registrations_for

Return every role attached to a possibly shared storage factory.

resource

Preserve authored hook signatures while attaching lifecycle metadata.

session

Observe committed sessions without participating in persistence.

session.created

Preserve authored hook signatures while attaching lifecycle metadata.

skills

Register named runtime catalogs independently of filesystem skills.

skills.source

Declare one named provider queried only during managed execution.

storage

Namespace storage roles while retaining distributed file discovery.

storage.sessions

Preserve authored hook signatures while attaching lifecycle metadata.

storage.checkpoints

Preserve authored hook signatures while attaching lifecycle metadata.

storage.tasks

Preserve authored hook signatures while attaching lifecycle metadata.

storage.cron

Preserve authored hook signatures while attaching lifecycle metadata.

storage.memory

Preserve authored hook signatures while attaching lifecycle metadata.

storage.assets

Declare one named asset authority assembled into the registry.

storage.custom

Declare lifecycle-owned application storage under an explicit name.

telemetry_exporter

Preserve authored hook signatures while attaching lifecycle metadata.

tool

Group portable tool interception under its first-class domain path.

tool.before

Preserve authored hook signatures while attaching lifecycle metadata.

tool.after

Preserve authored hook signatures while attaching lifecycle metadata.

tool.on_error

Preserve authored hook signatures while attaching lifecycle metadata.