Issho.Tool.Context (Issho v0.4.0)

Copy Markdown View Source

Who runs a tool: the agent (an Issho.Actor), the options of its joins (:on_behalf_of, :claims, :can), and the instance. A front end makes it from its caller: Issho.MCP from an MCP call, your code from the user your app's model works for.

ctx = Issho.Tool.Context.new(MyApp.Issho, %{id: "assistant:#{user.id}", name: "Assistant", kind: :agent},
  on_behalf_of: user)

The agent joins the rooms it works in and stays between calls, until it leaves or has been idle for :idle milliseconds (Issho.Agents).

Summary

Functions

A tool's error, as words the model reads.

The agent's participant in the room, joining it if it is not there.

The agent's key in the rooms.

Takes the agent out of the room.

A context: the instance, the agent, and :on_behalf_of, :claims, :can and :idle.

The agent's participant in the room, with the document (the room unless given) open.

A value the agent kept in the room, or nil.

Keeps a value for the agent in the room, for its later calls.

Types

t()

@type t() :: %Issho.Tool.Context{
  actor: Issho.Actor.t(),
  idle: pos_integer(),
  instance: atom(),
  opts: keyword()
}

Functions

error(reason)

@spec error(term()) :: {:error, String.t()}

A tool's error, as words the model reads.

join(ctx, room)

@spec join(t(), String.t()) :: {:ok, pid()} | {:error, term()}

The agent's participant in the room, joining it if it is not there.

key(context)

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

The agent's key in the rooms.

leave(ctx, room)

@spec leave(t(), String.t()) :: :ok

Takes the agent out of the room.

new(instance, actor, opts \\ [])

@spec new(atom(), Issho.Actor.t(), keyword()) :: t()

A context: the instance, the agent, and :on_behalf_of, :claims, :can and :idle.

open(ctx, room, document \\ nil)

@spec open(t(), String.t(), String.t() | nil) ::
  {:ok, pid(), String.t(), map()} | {:error, term()}

The agent's participant in the room, with the document (the room unless given) open.

recall(ctx, room, name)

@spec recall(t(), String.t(), term()) :: term()

A value the agent kept in the room, or nil.

remember(ctx, room, name, value)

@spec remember(t(), String.t(), term(), term()) :: :ok | {:error, :not_there}

Keeps a value for the agent in the room, for its later calls.