# `Issho.Tool.Context`
[🔗](https://github.com/hattoriai/issho/blob/v0.4.0/lib/issho/tool.ex#L212)

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`).

# `t`

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

# `error`

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

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

# `join`

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

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

# `key`

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

The agent's key in the rooms.

# `leave`

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

Takes the agent out of the room.

# `new`

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

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

# `open`

```elixir
@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`

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

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

# `remember`

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

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

---

*Consult [api-reference.md](api-reference.md) for complete listing*
