*/ abstract public function schema(): array; /** * Run the tool. Return a string (or scalar) — the agent will pass * this string back into the LLM as a tool observation. */ abstract public function execute(array $args): mixed; /** * Render the tool definition as the agent's prompt sees it. */ public function asPrompt(): string { $schema = $this->schema(); $args = []; foreach ($schema as $key => $def) { $args[] = " - $key ({$def['type']}): " . ($def['description'] ?? ''); } return sprintf( "Tool: %s\nWhat it does: %s\nArguments:\n%s", $this->name(), $this->description(), implode("\n", $args) ); } }