ToolContext
Context passed to tool handlers during agent loop execution. Provides access to the agent configuration, current conversation state, and arbitrary metadata for tool implementations that need broader context.
Class Diagram
Section titled “Class Diagram”---
title: ToolContext
config:
look: handDrawn
theme: colorful
class:
hideEmptyMembersBox: true
---
classDiagram
class ToolContext {
+Message[] messages
+dictionary metadata
}
class Message {
+string role
+ContentPart[] parts
+dictionary metadata
+toTextContent() unknown [async-capable]
+text() string [async-capable]
}
ToolContext *-- Message
Yaml Example
Section titled “Yaml Example”metadata: userId: user-123Properties
Section titled “Properties”| Name | Type | Description |
|---|---|---|
| messages | Message[] | The current conversation messages at the point of tool invocation |
| metadata | dictionary | Optional metadata for tool-specific context (e.g., user session info) |
Composed Types
Section titled “Composed Types”The following types are composed within ToolContext: