lifecycle/**/*.py add behavior around the agent. Harnest discovers decorated functions and ignores ordinary helpers.
Decorator index
| Decorator | Allowed | Purpose | Guide |
|---|---|---|---|
@lifecycle.resource | Many | Application dependency | Application resources |
@lifecycle.skills.source("name") | Many, with unique names | Dynamic skill catalog | Agent Skills |
@context.provider("name") | Many | Publish a resource | Application resources |
@lifecycle.agent.before/after/on_error | Many | Agent policy and observation | Invocation hooks |
@lifecycle.model.before/after/on_error | Many | Model policy and observation | Invocation hooks |
@lifecycle.tool.before/after/on_error | Many | Tool policy and observation | Invocation hooks |
@lifecycle.mcp.before/after/on_error | Many | Governed remote-tool policy | Invocation hooks |
@lifecycle.http.before/after/on_error | Many | HTTP request and response policy | Invocation hooks |
@lifecycle.evals.capture(store=...) | One, in lifecycle/evals_improvement.py | Production eval capture rule | Production eval capture |
@lifecycle.evals.redact | One, in lifecycle/evals_improvement.py | Team redaction policy for captured content | Production eval capture |
@lifecycle.output_policy | Zero or one | Public narration, tool activity, reasoning, and metadata | Output policy |
@lifecycle.adk_plugin | Many | ADK-native behavior | Native integrations |
@lifecycle.langgraph_middleware | Many | LangGraph-native behavior | Native integrations |
@lifecycle.http_routes | Many | Application HTTP routes | Custom HTTP endpoints |
@lifecycle.storage.sessions | Exactly one | Sessions and transcripts | Sessions |
@lifecycle.storage.checkpoints | Exactly one | In-progress execution | Checkpoints |
@lifecycle.storage.tasks | Zero or one | Durable task queue and results | Task and cron storage |
@lifecycle.storage.cron | Zero or one | Schedules and atomic occurrence handoff; shares the task provider instance | Task and cron storage |
@lifecycle.storage.assets("name") | Many, with unique names | Multimodal asset storage | Store and retrieve media |
@lifecycle.storage.custom("name") | Many, with unique names | Domain repositories | Sessions and application storage |
@lifecycle.authenticate | Zero or more | Request identity | Authentication |
@lifecycle.credential_provider | Zero or one | Downstream credentials | Authentication |
@lifecycle.telemetry_exporter | Many | Trace and log destination | Telemetry |
Factory rules
| Rule | Behavior |
|---|---|
| Signature | Synchronous and zero-argument unless it is a callback; http_routes receives one AgentInvoker |
| Return type | Must match the decorator’s resource or policy type |
| Duplicates | Single-owner factories reject duplicates |
| Ordering | Lower order, plugin dependency/source order, then source location |
| Ownership | Root agent only |
| Startup failure | Application does not serve |
| Shutdown | Harnest closes resources it owns |
Lifecycle overview
Choose the extension type before opening its focused guide.