Skip to content

Documentation / @agentick/core / SessionExecutionHandle

Interface: SessionExecutionHandle

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

Handle for interacting with a running session execution.

SessionExecutionHandle wraps the kernel's ExecutionHandle with session-specific methods using explicit delegation. This is the return type of session.send() and session.render().

The handle is AsyncIterable (not PromiseLike):

  • await handle.result → resolves to SendResult
  • for await (const event of handle) → streams StreamEvent

Example

typescript
// send/render are Procedures — await to get the handle
const handle = await session.send({ messages: [...] });

// Stream events
for await (const event of handle) {
  if (event.type === 'content_delta') {
    process.stdout.write(event.delta);
  }
}

// Or get result directly via ProcedurePromise chaining
const result = await session.send({ messages: [...] }).result;
console.log(result.response);

// Mid-execution interaction
handle.queueMessage({ role: "user", content: [...] });
handle.abort("User cancelled");

Extends

Properties

[ExecutionHandleBrand]

readonly [ExecutionHandleBrand]: true

Defined in: kernel/src/procedure.ts:260

Brand identifying this as an ExecutionHandle (not a plain AsyncIterable)

Inherited from

ExecutionHandle.[ExecutionHandleBrand]


currentTick

readonly currentTick: number

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

Current tick number


events

readonly events: EventBuffer<StreamEvent>

Defined in: kernel/src/procedure.ts:283

Event buffer for streaming execution events. Supports dual consumption - multiple iterators can independently consume all events. Late subscribers receive replayed events from the start.

API is compatible with EventEmitter: on, once, off, emit, addListener, removeListener. Use on('eventType', handler) to subscribe to specific event types. Use on(handler) or on('*', handler) for wildcard subscription.

Inherited from

ExecutionHandle.events


result

readonly result: Promise<SendResult>

Defined in: kernel/src/procedure.ts:292

Promise that resolves with the final result. Use await handle.result to get the value.

Inherited from

ExecutionHandle.result


sessionId

readonly sessionId: string

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

The session ID


status

readonly status: "error" | "pending" | "running" | "completed" | "failed" | "cancelled" | "aborted"

Defined in: kernel/src/procedure.ts:262

Current execution status

Inherited from

ExecutionHandle.status


traceId

readonly traceId: string

Defined in: kernel/src/procedure.ts:272

Trace ID for distributed tracing correlation

Inherited from

ExecutionHandle.traceId

Methods

[asyncIterator]()

[asyncIterator](): AsyncIterator<StreamEvent>

Defined in: kernel/src/procedure.ts:295

Returns

AsyncIterator<StreamEvent>

Inherited from

ExecutionHandle.[asyncIterator]


abort()

abort(reason?): void

Defined in: kernel/src/procedure.ts:286

Abort the execution

Parameters

reason?

string

Returns

void

Inherited from

ExecutionHandle.abort


queueMessage()

queueMessage(message): void

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

Queue a message during execution. Delivered to onMessage hooks if running, queued for next tick otherwise.

Parameters

message

Message

Returns

void


submitToolResult()

submitToolResult(toolUseId, response): void

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

Submit a tool confirmation result. Used when a tool requires user confirmation.

Parameters

toolUseId

string

response
approved

boolean

modifiedArguments?

Record<string, unknown>

reason?

string

Returns

void

Released under the ISC License.