Skip to content
Prompty

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.

---
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
    }
    ToolContext *-- Message
metadata:
userId: user-123
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)

The following types are composed within ToolContext: