# CallbackContext

class CallbackContext(invocationContext: InvocationContext, eventActions: EventActions? = null) : ReadonlyContext

The context provided to agents and tools during a callback, such as when a tool is run.

It provides access to the current invocation context, event actions, and state.

## Constructors

CallbackContext
Link copied to clipboard
constructor(invocationContext: InvocationContext, eventActions: EventActions? = null)

## Properties

agent
Link copied to clipboard
val agent: BaseAgent
agentName
Link copied to clipboard
open override val agentName: String

The name of the agent that is being invoked.

artifactService
Link copied to clipboard
open override val artifactService: ArtifactService?

The ArtifactService instance.

branch
Link copied to clipboard
open override val branch: String?

The branch of the invocation context.

eventActions
Link copied to clipboard
var eventActions: EventActions
invocationId
Link copied to clipboard
open override val invocationId: String

The unique ID of this invocation.

memoryService
Link copied to clipboard
open override val memoryService: MemoryService?

The MemoryService instance.

runConfig
Link copied to clipboard
open override val runConfig: RunConfig?

The run configuration for this invocation.

session
Link copied to clipboard
open override val session: Session

The session that this invocation is a part of.

state
Link copied to clipboard
open override val state: Map<String, Any>

The state of the session.

userContent
Link copied to clipboard
open override val userContent: Content?

The user content that this invocation is processing.

userId
Link copied to clipboard
open override val userId: String

The user ID of the user that initiated the session.

## Functions

addSessionToMemory
Link copied to clipboard
suspend fun addSessionToMemory()

Triggers memory generation for the current session.

getEvents
Link copied to clipboard
open suspend override fun getEvents(currentInvocation: Boolean, currentBranch: Boolean): List<Event>

Returns the events from the current session.

mergeEventActions
Link copied to clipboard
fun mergeEventActions(actions: EventActions)

Merges the given event actions into the current event actions.

updateState
Link copied to clipboard
fun updateState(key: String, value: Any)

Updates the state delta in the event actions.