MastraM
Mastra2mo ago
12 replies
Eric Burel

Calling an agent: returns a tool call without iterating

When calling
generate
from my agent, it returns a tool call request, but doesn't carry on with processing it. I am on a non standard environment, a Deno script, but I don't think this could affect the output.
Am I missing something? Here is the agent pseudo code :
import { Agent } from "@mastra/core/agent";
import { RuntimeContext } from "@mastra/core/runtime-context";
const fileExplorerAgent = new Agent({
    model: "mistral/ministral-3b-latest",
    instructions: `
    You are a file explorer agent.
    Answer user questions about a folder.
    You are provided tools to scan the folder, list files, dive into nested folders.
    Use the appropriate tools to answer questions.
    `,
    name: "file-explorer",
    tools: [scanFolder],
    defaultGenerateOptions: {
        maxSteps: 10
    }
})
    const runtimeContext = new RuntimeContext<{ rootFolder: string }>()
    runtimeContext.set("rootFolder", rootFolder)
    const msg = await fileExplorerAgent.generate([
        {
            role: "user",
            content: prompt
        },
    ], { runtimeContext })
    console.log("File Explorer says:", msg.text, msg.toolCalls)

The "scanFolder" tool is correctly called but the agent stops there instead of looping as usual.
maxSteps
doesn't change this behaviour. Perhaps the tool fails to run?
Was this page helpful?