Alloy.Memory.Router (alloy v0.12.4)

Copy Markdown View Source

Routes memory_20250818 tool calls to a configured Alloy.Memory store.

This module is deliberately independent of Alloy.Tool.Executor. Anthropic's memory tool is a typed tool ({"type": "memory_20250818"}), not a generic function tool — its command vocabulary, argument shape, and result-string conventions are fixed by the provider contract, so it does not benefit from the generic tool pipeline's concurrency, tagging, or schema validation.

The router's job is narrow: take a list of memory tool-use blocks, dispatch each command to the store in order, and return the matching tool_result blocks.

Summary

Functions

Dispatch a list of memory tool-use blocks to the configured store.

Predicate: is this tool-use block a memory call?

Returns the tool name that provider wiring uses for the memory_20250818 tool. Exposed so providers and Turn can partition tool calls without re-declaring the string.

Functions

dispatch_all(tool_calls, arg)

@spec dispatch_all(
  [map()],
  {module(), term()}
) :: [map()]

Dispatch a list of memory tool-use blocks to the configured store.

Returns [%{type: "tool_result", tool_use_id: id, content: text, is_error: bool}] in the same order as the input blocks.

memory_config is the {module, opts} tuple that Alloy.run/2 received as the :memory option. The second element is passed to every callback as the opaque store term.

memory_call?(arg1)

@spec memory_call?(map()) :: boolean()

Predicate: is this tool-use block a memory call?

tool_name()

@spec tool_name() :: String.t()

Returns the tool name that provider wiring uses for the memory_20250818 tool. Exposed so providers and Turn can partition tool calls without re-declaring the string.