- Issue created by @Akhil Babu
I have an AI agent that functions as an assistant. The assistant has history turned off. The agent uses two sub-agent tools, which are prompted to provide a JSON response. Both tools have "Return directly" enabled, as their output doesn’t need to be sent back to the main agent.
In the earlier release of AI Agents version 1.1, this setup worked fine. But now, when a tool returns something directly, the agent job is marked as "Not solved", and the chat history is saved in tempstore.
// Drupal\ai_assistant_api\Service\AgentRunner::runAsAgent
$agent->determineSolvability();
// If the agent is still running, we store it for the next run.
if (!$agent->isFinished()) {
// This gets executed
$this->tempStore->get('ai_assistant_threads')->set($job_id, $agent->toArray());
}
else {
// Cleanup when finished.
$this->tempStore->get('ai_assistant_threads')->delete($job_id);
}
So when the main agent is called for the second time, this stored data gets added to the current request which breaks the agent flow.
I am not sure if this is a bug or this is how it is supposed to work. As a workaround, I am manually deleting the thread after every response
$response = $this->aiAssistantClient->process();
// Delete the thread from the temp store after processing.
$this->tempStore->get('ai_assistant_threads')->delete($this->aiAssistantClient->getThreadsKey());
Active
1.1
Code