AgentToolsAgent::ask()
Ask a question and get a text response
This is the primary public API for sending a request to the agent. It handles message formatting and returns a plain text response.
Example
$agent = $at->getPrimaryAgent();
$answer = $agent->ask('What is the capital of France?');
// With a system prompt:
$answer = $agent->ask('Summarize this content: ' . $body, 'You are a concise copywriter.');
// With provider-specific options:
$answer = $agent->ask('Draft a tagline.', '', [
'timeout' => 30,
'openai' => ['temperature' => 0.9, 'max_output_tokens' => 256],
]);Usage
// basic usage
$string = $agentToolsAgent->ask(string $question);
// usage with all arguments
$string = $agentToolsAgent->ask(string $question, string $systemPrompt = '', array $options = []);Arguments
| Name | Type(s) | Description |
|---|---|---|
$question | string | The question or request to send |
$systemPrompt (optional) | string | Optional instructions for the AI (leave blank for none) |
$options (optional) | array | Optional request options — see sendRequest() for supported keys |
Return value
stringText response from the AI, or error message string if the request failed
AgentToolsAgent methods and properties
API reference based on ProcessWire core version 3.0.263