> ## Documentation Index
> Fetch the complete documentation index at: https://usefused.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Lifecycle reference

> Find each lifecycle decorator, its allowed count, and its detailed guide.

Root files under `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](/docs/harnest/runtime/lifecycle/application-resources)                         |
| `@lifecycle.skills.source("name")`       | Many, with unique names | Dynamic skill catalog                                                      | [Agent Skills](/docs/harnest/build/agent-skills)                                                       |
| `@context.provider("name")`              |                    Many | Publish a resource                                                         | [Application resources](/docs/harnest/runtime/lifecycle/application-resources)                         |
| `@lifecycle.agent.before/after/on_error` |                    Many | Agent policy and observation                                               | [Invocation hooks](/docs/harnest/runtime/lifecycle/invocation-hooks)                                   |
| `@lifecycle.model.before/after/on_error` |                    Many | Model policy and observation                                               | [Invocation hooks](/docs/harnest/runtime/lifecycle/invocation-hooks)                                   |
| `@lifecycle.tool.before/after/on_error`  |                    Many | Tool policy and observation                                                | [Invocation hooks](/docs/harnest/runtime/lifecycle/invocation-hooks)                                   |
| `@lifecycle.mcp.before/after/on_error`   |                    Many | Governed remote-tool policy                                                | [Invocation hooks](/docs/harnest/runtime/lifecycle/invocation-hooks)                                   |
| `@lifecycle.http.before/after/on_error`  |                    Many | HTTP request and response policy                                           | [Invocation hooks](/docs/harnest/runtime/lifecycle/invocation-hooks)                                   |
| `@lifecycle.output_policy`               |             Zero or one | Public narration, tool activity, reasoning, and metadata                   | [Output policy](/docs/harnest/runtime/lifecycle/output-policy)                                         |
| `@lifecycle.adk_plugin`                  |                    Many | ADK-native behavior                                                        | [Native integrations](/docs/harnest/runtime/lifecycle/native-integrations)                             |
| `@lifecycle.langgraph_middleware`        |                    Many | LangGraph-native behavior                                                  | [Native integrations](/docs/harnest/runtime/lifecycle/native-integrations)                             |
| `@lifecycle.http_routes`                 |                    Many | Application HTTP routes                                                    | [Custom HTTP endpoints](/docs/harnest/runtime/custom-http-endpoints)                                   |
| `@lifecycle.storage.sessions`            |             Exactly one | Sessions and transcripts                                                   | [Sessions](/docs/harnest/runtime/session-storage)                                                      |
| `@lifecycle.storage.checkpoints`         |             Exactly one | In-progress execution                                                      | [Checkpoints](/docs/harnest/runtime/checkpoints)                                                       |
| `@lifecycle.storage.tasks`               |             Zero or one | Durable task queue and results                                             | [Task and cron storage](/docs/harnest/runtime/task-storage)                                            |
| `@lifecycle.storage.cron`                |             Zero or one | Schedules and atomic occurrence handoff; shares the task provider instance | [Task and cron storage](/docs/harnest/runtime/task-storage)                                            |
| `@lifecycle.storage.assets("name")`      | Many, with unique names | Multimodal asset storage                                                   | [Store and retrieve media](/docs/harnest/build/models-and-libraries/store-and-retrieve-media)          |
| `@lifecycle.storage.custom("name")`      | Many, with unique names | Domain repositories                                                        | [Sessions and application storage](/docs/harnest/runtime/session-storage#register-a-domain-repository) |
| `@lifecycle.authenticate`                |            Zero or more | Request identity                                                           | [Authentication](/docs/harnest/runtime/authentication-and-credentials)                                 |
| `@lifecycle.credential_provider`         |             Zero or one | Downstream credentials                                                     | [Authentication](/docs/harnest/runtime/authentication-and-credentials)                                 |
| `@lifecycle.telemetry_exporter`          |                    Many | Trace and log destination                                                  | [Telemetry](/docs/harnest/runtime/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                                                                 |

<Card title="Lifecycle overview" icon="arrows-rotate" href="/docs/harnest/runtime/lifecycle">
  Choose the extension type before opening its focused guide.
</Card>
