AgentToolSpec

org.llm4s.agent.graph.tool.AgentToolSpec
See theAgentToolSpec companion object
final case class AgentToolSpec[A]

What a tool tells the model and the loop: its name, description and argument schema, how its arguments decode, an optional check on the decoded value, and the question it may ask.

name must match [a-zA-Z0-9_-]{1,64}: apply throws IllegalArgumentException otherwise, and ToolSet.of refuses one too, so a spec built another way is still checked.

Arguments are validated against argumentSchema, the schema rendered non-strict, which is what core's Anthropic, Gemini and Vertex AI clients send. A call from a client that sends tools strict (OpenAI and the OpenAI-compatible ones) carries every property, which that schema also accepts.

Value parameters

question

the question this tool may ask; set by AgentTool.Asking

validateDecoded

a check on the decoded arguments; Left becomes an error the model sees

Attributes

Companion
object
Graph
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

def toolDefinition: Value

The tool definition in OpenAI's strict format, the shape of ToolFunction.toOpenAITool(true), for callers that send definitions themselves; core's clients receive ToolSet.toolFunctions and render their own from schema. Its parameters are a fresh copy each time, so a caller that edits one definition cannot change another.

The tool definition in OpenAI's strict format, the shape of ToolFunction.toOpenAITool(true), for callers that send definitions themselves; core's clients receive ToolSet.toolFunctions and render their own from schema. Its parameters are a fresh copy each time, so a caller that edits one definition cannot change another.

Attributes

def withValidation(check: A => Result[Unit]): AgentToolSpec[A]

Adds a check on the decoded arguments, replacing any earlier one.

Adds a check on the decoded arguments, replacing any earlier one.

Attributes

Inherited methods

def productElementNames: Iterator[String]

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

Attributes

Inherited from:
Product

Concrete fields

lazy val argumentSchema: Value

The schema arguments are validated against, schema.toJsonSchema(strict = false), rendered once: only the required properties are required, so a call that omits an optional one is accepted, as core's non-strict clients allow. ToolSet.of checks its keywords. Do not mutate it.

The schema arguments are validated against, schema.toJsonSchema(strict = false), rendered once: only the required properties are required, so a call that omits an optional one is accepted, as core's non-strict clients allow. ToolSet.of checks its keywords. Do not mutate it.

Attributes

Givens

Givens

given codec: ReadWriter[A]