baseUri = rtrim( $endpoint, '/' ) . '/api/v1'; // Model name doesn't matter — server's QueryClassifier/ModelRouter overrides it. parent::__construct( $api_key, 'aisentic-auto' ); } /** * @param ToolInterface[] $tools */ public function set_pool_tools( array $tools ): void { $this->pool_tools = $tools; } /** * Resolve a tool call, falling back to the pool. * * The model can name a pool tool it never discovered, and the parent treats * that as an invented name and throws. The tool exists, so running it beats * ending the turn. A name in neither list is still an error. * * @throws ProviderException When no registered or pool tool carries the name. */ public function findTool( string $name ): ToolInterface { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.MethodNameInvalid -- Overrides a vendor method. try { return parent::findTool( $name ); } catch ( ProviderException $e ) { foreach ( $this->pool_tools as $tool ) { if ( $tool->getName() === $name ) { // Cloned for the same reason the parent clones: a tool carries // per-call inputs and results. return clone $tool; } } throw $e; } } }