# `PtcRunner.SubAgent.SubAgentTool`
[🔗](https://github.com/andreasronge/ptc_runner/blob/main/lib/ptc_runner/sub_agent/sub_agent_tool.ex#L1)

Wraps a SubAgent as a callable tool for parent agents.

Created via `SubAgent.as_tool/2`, this struct allows agents to be
composed and nested. When a parent agent calls a SubAgentTool,
the wrapped agent executes with inherited LLM and registry.

## LLM Resolution Order

When a SubAgentTool is called, the LLM is resolved in this priority order:

1. `agent.llm` - Agent's own LLM override (highest priority)
2. `bound_llm` - LLM bound at tool creation via `as_tool/2`
3. Parent's llm - Inherited from the calling agent at call time (lowest priority)

This allows flexible composition where child agents can use their own LLM,
inherit from the parent, or use a specifically bound LLM.

## Fields

- `agent` - The `SubAgent.t()` to wrap as a tool
- `bound_llm` - Optional LLM (atom or function) bound at tool creation
- `signature` - Type signature (copied from agent.signature)
- `description` - Optional description (defaults to agent's prompt)
- `cache` - Enable result caching by input args (default: `false`).
  Only use for deterministic agents where same inputs always produce same outputs.

# `t`

```elixir
@type t() :: %PtcRunner.SubAgent.SubAgentTool{
  agent: PtcRunner.SubAgent.t(),
  bound_llm: atom() | (map() -&gt; {:ok, String.t()} | {:error, term()}) | nil,
  cache: boolean(),
  description: String.t() | nil,
  signature: String.t() | nil
}
```

---

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