withToolCallContext

open override fun withToolCallContext(context: ToolCallContext): PromptRunner

Set out-of-band metadata to pass to tools at call time.

The context flows through the tool loop to every tool invoked during this interaction. For MCP tools, entries are forwarded as MCP _meta on the wire (subject to any com.embabel.agent.tools.mcp.ToolCallContextMcpMetaConverter bean configured in the application).

This context is merged with any context set at the process level via com.embabel.agent.core.ProcessOptions. Interaction-level values win on conflict.

Example:

ai.promptRunner()
.withToolCallContext(ToolCallContext.of("tenantId" to "acme", "locale" to "en-AU"))
.withToolGroup(CoreToolGroups.WEB)
.createObject<NewsResult>(prompt)

Return

PromptRunner with the tool call context set

Parameters

context

the context entries to attach