extensions/**/*.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 |
@context("name") | Many | Publish a resource | Application resources |
@lifecycle.before_agent / after_agent | Many | Agent policy and observation | Invocation hooks |
@lifecycle.before_model / after_model | Many | Model policy and observation | Invocation hooks |
@lifecycle.before_tool / after_tool | Many | Tool policy and observation | Invocation hooks |
@lifecycle.output_policy | Zero or one | Public SubAgent messages | 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.asset_store | Zero or one | Multimodal asset storage | Typed multimodal contracts |
@lifecycle.session_store | Exactly one | Sessions and transcripts | Storage |
@lifecycle.checkpointer | Exactly one | In-progress execution | 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 | Explicit order, then source path |
| 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.