Skip to content

agent-sessions / Exports / Session

Class: Session

Session class.

Maintains conversation history by keeping the same Robota agent across multiple run() calls. The session ID is stable for the lifetime of the object.

Table of contents

Constructors

Methods

Constructors

constructor

new Session(options): Session

Parameters

NameType
optionsISessionOptions

Returns

Session

Defined in

agent-sessions/src/session.ts:99

Methods

run

run(message): Promise<string>

Send a message to the agent and return the response.

Parameters

NameType
messagestring

Returns

Promise<string>

Defined in

agent-sessions/src/session.ts:198


getPermissionMode

getPermissionMode(): TPermissionMode

Return the active permission mode

Returns

TPermissionMode

Defined in

agent-sessions/src/session.ts:316


setPermissionMode

setPermissionMode(mode): void

Change the active permission mode. Future tool calls will be evaluated against the new mode.

Parameters

NameType
modeTPermissionMode

Returns

void

Defined in

agent-sessions/src/session.ts:324


getSessionId

getSessionId(): string

Return the stable session identifier

Returns

string

Defined in

agent-sessions/src/session.ts:329


getMessageCount

getMessageCount(): number

Return the number of run() calls completed

Returns

number

Defined in

agent-sessions/src/session.ts:334


getSessionAllowedTools

getSessionAllowedTools(): string[]

Get tools that have been session-approved (via "Allow always" choice).

Returns

string[]

Defined in

agent-sessions/src/session.ts:339


clearSessionAllowedTools

clearSessionAllowedTools(): void

Clear all session-scoped allow rules.

Returns

void

Defined in

agent-sessions/src/session.ts:344


abort

abort(): void

Abort the currently running execution. No-op if nothing is running.

Returns

void

Defined in

agent-sessions/src/session.ts:349


isRunning

isRunning(): boolean

Whether a run() call is currently in progress.

Returns

boolean

Defined in

agent-sessions/src/session.ts:357


getContextState

getContextState(): IContextWindowState

Get current context window state

Returns

IContextWindowState

Defined in

agent-sessions/src/session.ts:362


compact

compact(instructions?): Promise<void>

Run compaction — summarize the conversation to free context space.

Parameters

NameTypeDescription
instructions?stringOptional focus instructions for the summary

Returns

Promise<void>

Defined in

agent-sessions/src/session.ts:370


clearHistory

clearHistory(): void

Clear conversation history

Returns

void

Defined in

agent-sessions/src/session.ts:408


getHistory

getHistory(): TUniversalMessage[]

Get conversation history

Returns

TUniversalMessage[]

Defined in

agent-sessions/src/session.ts:414

Released under the MIT License.