fix: use web search in SpecsResearchAgent to prevent spec hallucination

The agent was calling generate() — pure model memory — which caused Mistral
to hallucinate specs for older devices (e.g. i5-1135G7 instead of i3-3120M).
generateWithWebSearch() is now used so Mistral queries live sources.

OllamaClientInterface gains generateWithWebSearch(); OllamaClient falls back
to generate() since Ollama has no built-in search tool.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Simon Kuehn 2026-05-18 07:28:21 +00:00
parent d5a1353a8b
commit a38fe7e72d
3 changed files with 9 additions and 1 deletions

View file

@ -25,7 +25,7 @@ final class SpecsResearchAgent
'subject' => $subject, 'subject' => $subject,
]); ]);
$result = $this->client->generate($this->model, $prompt); $result = $this->client->generateWithWebSearch($this->model, $prompt);
if ('' === trim($result)) { if ('' === trim($result)) {
throw new \RuntimeException("No specifications found for model: {$modelName}"); throw new \RuntimeException("No specifications found for model: {$modelName}");

View file

@ -50,4 +50,9 @@ final class OllamaClient implements OllamaClientInterface
return $data['response']; return $data['response'];
} }
public function generateWithWebSearch(string $model, string $prompt): string
{
return $this->generate($model, $prompt);
}
} }

View file

@ -9,4 +9,7 @@ interface OllamaClientInterface
public function generate(string $model, string $prompt): string; public function generate(string $model, string $prompt): string;
public function generateWithImage(string $model, string $prompt, string $imagePath): string; public function generateWithImage(string $model, string $prompt, string $imagePath): string;
/** Generates with web search if the backend supports it, falls back to generate(). */
public function generateWithWebSearch(string $model, string $prompt): string;
} }