Normandy.Tools.Context (normandy v2.2.0)

View Source

What a tool knows about the call it serves; the second argument of Normandy.Tool.run/2.

Built per tool call by the dispatch pipeline from the agent config, the %ToolCall{} and the validated input. input is the model's input after Normandy.Tools.Input.validate/2: a struct of the tool's declared input schema, or a string-keyed map. values is the config's tool_context: plain data the application sets per session (for example %{memory_namespace: "acme/user-42"}). It is persisted in the session's config template, so it must hold no secrets; resolve secrets through Normandy.Behaviours.CredentialProvider, keyed by a value from here.

The model sets only input, and only through validation; the tool struct and the rest of the context are out of its reach.

Summary

Functions

Builds the context for call from config (a %BaseAgentConfig{} or a partial map) and the call's validated input.

Types

t()

@type t() :: %Normandy.Tools.Context{
  agent_name: String.t() | nil,
  input: struct() | map() | nil,
  session_id: String.t() | nil,
  tool_call_id: String.t() | nil,
  turn_id: String.t() | nil,
  values: map()
}

Functions

build(config, call, input)

@spec build(map(), Normandy.Components.ToolCall.t(), struct() | map()) :: t()

Builds the context for call from config (a %BaseAgentConfig{} or a partial map) and the call's validated input.