Skip to content

Documentation / @agentick/core / LifecycleCallbacks

Interface: LifecycleCallbacks ​

Defined in: core/src/app/types.ts:62

Lifecycle callbacks for session execution.

These provide a cleaner alternative to event listeners for common lifecycle events. Callbacks defined on AppOptions are inherited by all sessions; callbacks on SessionOptions override or supplement them.

Example ​

typescript
const app = createApp(MyAgent, {
  model,
  onTickStart: (tick) => console.log(`Tick ${tick} starting`),
  onComplete: (result) => console.log(`Done: ${result.response}`),
});

// Session can add its own callbacks
const session = app.session({
  onEvent: (event) => { ... }, // Receives all events
});

Extended by ​

Properties ​

onComplete()? ​

optional onComplete: (result) => void

Defined in: core/src/app/types.ts:87

Called when execution completes successfully.

Parameters ​

result ​

SendResult

The final result

Returns ​

void


onError()? ​

optional onError: (error) => void

Defined in: core/src/app/types.ts:93

Called when an error occurs during execution.

Parameters ​

error ​

Error

The error that occurred

Returns ​

void


onEvent()? ​

optional onEvent: (event) => void

Defined in: core/src/app/types.ts:67

Called for every stream event. Use this for fine-grained event handling.

Parameters ​

event ​

StreamEvent

Returns ​

void


onTickEnd()? ​

optional onTickEnd: (tick, usage?) => void

Defined in: core/src/app/types.ts:81

Called when a tick ends.

Parameters ​

tick ​

number

The tick number

usage? ​

UsageStats

Token usage for this tick

Returns ​

void


onTickStart()? ​

optional onTickStart: (tick, executionId) => void

Defined in: core/src/app/types.ts:74

Called when a tick starts.

Parameters ​

tick ​

number

The tick number (1-indexed)

executionId ​

string

The execution ID

Returns ​

void

Released under the ISC License.