provideToolCallMetadata
expect open override fun provideToolCallMetadata(feature: AIAgentFeature<*, *>, handle: suspend (eventContext: ToolCallStartingContext) -> Map<String, Any?>)(source)
Registers a handler that contributes per-call metadata before a tool executes.
The handler receives the same ToolCallStartingContext as interceptToolCallStarting and returns a Map<String, Any?> that is merged into the metadata passed to ai.koog.agents.core.tools.Tool.execute.
Parameters
feature
The feature associated with this handler.
handle
A suspend function returning the metadata entries this feature wants to contribute.
Example:
pipeline.provideToolCallMetadata(feature) { eventContext ->
mapOf("trace.span.id" to currentSpan()?.id)
}Content copied to clipboard