M
Mastra2mo ago
Vulcano

agent.generate() result does not contain reasoning.

Reproduction:
import { openai } from "@ai-sdk/openai";
import { Agent } from "@mastra/core/agent";
import { describe, expect, it } from "vitest";

const reasoningAgent = new Agent({
name: 'reasoningAgent',
instructions: `You are a reasoning agent. Think very carefully about the problem you are given and come up with the best solution.`,
model: openai('gpt-5'),
});

describe('reasoning tests', () => {
it('should provide reasoning text', async () => {
const result = await reasoningAgent.generate(
[
{
role: 'user',
content: 'If John has 2 apples and Jane has 3 apples, then John gives one apple to Jane, how many apples does John have left?',
}
],
{
providerOptions:
{
openai:
{
reasoningEffort: 'high',
},
},
},
);
expect(result.text.length).toBeGreaterThan(0);
expect(result.reasoningText).toBeDefined();
expect(result.reasoningText?.length).toBeGreaterThan(0);
});
});
import { openai } from "@ai-sdk/openai";
import { Agent } from "@mastra/core/agent";
import { describe, expect, it } from "vitest";

const reasoningAgent = new Agent({
name: 'reasoningAgent',
instructions: `You are a reasoning agent. Think very carefully about the problem you are given and come up with the best solution.`,
model: openai('gpt-5'),
});

describe('reasoning tests', () => {
it('should provide reasoning text', async () => {
const result = await reasoningAgent.generate(
[
{
role: 'user',
content: 'If John has 2 apples and Jane has 3 apples, then John gives one apple to Jane, how many apples does John have left?',
}
],
{
providerOptions:
{
openai:
{
reasoningEffort: 'high',
},
},
},
);
expect(result.text.length).toBeGreaterThan(0);
expect(result.reasoningText).toBeDefined();
expect(result.reasoningText?.length).toBeGreaterThan(0);
});
});
4 Replies
Mastra Triager
Mastra Triager2mo ago
GitHub
[DISCORD:1433070558303748248] agent.generate() result does not cont...
This issue was created from Discord post: https://discord.com/channels/1309558646228779139/1433070558303748248 Reproduction: import { openai } from "@ai-sdk/openai"; import { Agent } from...
_roamin_
_roamin_2mo ago
Hey @Vulcano ! Are you using the latest Mastra packages? I'm not able to reproduce
Vulcano
VulcanoOP2mo ago
Taking a look This test fails for me with the following dependencies:
"@ai-sdk/openai": "2.0.30",
"@mastra/core": "0.21.0",
"mastra": "0.16.0",
"zod": "^3.24.4"

Dev dependencies:
"typescript": "^5.8.3",
"@ai-sdk/openai": "2.0.30",
"@mastra/core": "0.21.0",
"mastra": "0.16.0",
"zod": "^3.24.4"

Dev dependencies:
"typescript": "^5.8.3",
Also fails with mastra: 0.17.7 + @mastra/core: 0.23.3 + @ai-sdk/openai: 2.0.58
nodejs 22.11.0
pnpm 10.12.4
nodejs 22.11.0
pnpm 10.12.4
Does this test really pass for you? I cannot get the result to contain reasoning. I tried many configs now. Maybe its smth in openai?
Tyler
Tyler4w ago
yeah openai doesn't ever send reasoning, they keep it private

Did you find this page helpful?