Skip to content

[Feature] agents: ToolRegistry with tools-as-actors (absorbs #202) #423

Description

@pathosDev

Part of the agents epic #421. Absorbs #202 (LLM-Tool-Call-as-Actor primitive).

Rationale

Tool calls are the failure hotspot of agent systems. Modeling each tool as an ActorRef gives supervision (restart-with-backoff), timeout, retry and circuit-breaking — with the framework's existing primitives instead of bespoke plumbing.

Scope

  • ToolDefinition (name, description, input/output schema → JSON Schema for the wire, timeoutMs, retry, circuitBreaker, idempotent, requiresApproval).
  • ToolInvoke / ToolReply protocol (kind-discriminated named variant types, replyTo so ActorRef.ask() correlates; W3C trace-carrier field).
  • ToolRegistry: register(definition, actorRef) for any actor speaking the protocol; registerFunction(definition, fn) spawning a supervised FunctionToolActor (BackoffSupervisor); specifications() for the model-facing tool list; invoke() = validate → ask with timeout/retry/CircuitBreaker.
  • Supervision semantics: a crashing tool actor is restarted by its supervisor; the agent sees a ToolReply failure — default policy "report the error to the model as the tool result" (LLMs recover well), escalation configurable.
const getWeather = tool({
  name: 'get_weather',
  description: 'Current weather for a city',
  inputSchema: z.object({ city: z.string() }),
  timeoutMs: 5_000,
  retry: { maxRetries: 2 },
  idempotent: true,        // may be re-executed after crash recovery
}, async ({ city }) => fetchWeather(city));

Documentation

Concept page "Tools" (EN + DE); JSDoc; CHANGELOG.

Acceptance

  • Schema-invalid input is rejected before the actor is asked; timeout/retry/CircuitBreaker behavior verified under ManualScheduler; supervision restart covered; trace carrier propagated.

Non-goals

Cluster-wide receptionist-backed registry (follow-up); MCP (separate issues).

Relates

Epic #421; #202 (absorbed). Conventions per AGENTS.md (kind discriminant, onXxx delegation, options family).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestpriority: highTop priority — high impact, plan next

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions