Two mechanisms let you observe and constrain a Karta app without touching the harness: hooks (react to lifecycle events) and policies (validate messages before they run).Documentation Index
Fetch the complete documentation index at: https://docs.karta.sh/llms.txt
Use this file to discover all available pages before exploring further.
Hooks
Register a handler for a lifecycle event with@app.on(...). Handlers receive a
HookEvent carrying the session, message, and any event-specific payload.
Available events
| Event | Fires when |
|---|---|
session.created | A new session is opened. |
message.received | An inbound message is accepted, before the turn runs. |
message.completed | A turn finishes and the assistant message is ready. |
agent.handoff | A session’s current_agent changes. |
Policies
Policies validate messages against configurable rules before a turn runs — length limits, message counts, keyword gates.Hooks and policies run in the thin core of the data plane — they’re part
of orchestration, not the harness. They don’t see or alter conversation
history (the harness owns that); they gate and observe the turns that flow
through Karta. See Architecture.