calling default*Options dynamic configuration option is not logical

my tests with console.log, that demonstrates that only defaultVNextStreamOptions is called nevertheless agent.generate or agent.stream were called.
gitlabAgent.generate
defaultVNextStreamOptions called

stdout | src/mastra/index.test.ts > Mastra > Agent.generate() > should handle conversation with multiple messages
gitlabAgent.generate
defaultVNextStreamOptions called

stdout | src/mastra/index.test.ts > Mastra > Agent.stream() > should stream text response in chunks
gitlabAgent.stream
defaultVNextStreamOptions called

stdout | src/mastra/index.test.ts > Mastra > Agent.stream() > should handle single chunk stream
gitlabAgent.stream
defaultVNextStreamOptions called
gitlabAgent.generate
defaultVNextStreamOptions called

stdout | src/mastra/index.test.ts > Mastra > Agent.generate() > should handle conversation with multiple messages
gitlabAgent.generate
defaultVNextStreamOptions called

stdout | src/mastra/index.test.ts > Mastra > Agent.stream() > should stream text response in chunks
gitlabAgent.stream
defaultVNextStreamOptions called

stdout | src/mastra/index.test.ts > Mastra > Agent.stream() > should handle single chunk stream
gitlabAgent.stream
defaultVNextStreamOptions called
my agent is defined as:
import { Agent } from "@mastra/core/agent";
import { Memory } from "@mastra/memory";
import { gitlabGraphQLTool } from "./gitlab-graphql.tool";
import { gitlabRestTool } from "./gitlab-rest.tool";
import { defaultProvider } from "../providers";
import { GitLabClient } from "./gitlab.client";

const gitlabClient = new GitLabClient();

export const gitlabAgent = new Agent({
name: "gitlab-agent",
instructions: "You are a helpful assistant.",
model: defaultProvider,
memory: new Memory({}),
defaultGenerateOptions: (context) => {
console.log("defaultGenerateOptions called");
context.runtimeContext.set("gitlabClient", gitlabClient);
return context;
},
defaultStreamOptions: (context) => {
console.log("defaultStreamOptions called");
context.runtimeContext.set("gitlabClient", gitlabClient);
return context;
},
defaultVNextStreamOptions: (context) => {
console.log("defaultVNextStreamOptions called");
context.runtimeContext.set("gitlabClient", gitlabClient);
return context;
},
tools: {
gitlabGraphQL: gitlabGraphQLTool,
gitlabRest: gitlabRestTool,
},
});
import { Agent } from "@mastra/core/agent";
import { Memory } from "@mastra/memory";
import { gitlabGraphQLTool } from "./gitlab-graphql.tool";
import { gitlabRestTool } from "./gitlab-rest.tool";
import { defaultProvider } from "../providers";
import { GitLabClient } from "./gitlab.client";

const gitlabClient = new GitLabClient();

export const gitlabAgent = new Agent({
name: "gitlab-agent",
instructions: "You are a helpful assistant.",
model: defaultProvider,
memory: new Memory({}),
defaultGenerateOptions: (context) => {
console.log("defaultGenerateOptions called");
context.runtimeContext.set("gitlabClient", gitlabClient);
return context;
},
defaultStreamOptions: (context) => {
console.log("defaultStreamOptions called");
context.runtimeContext.set("gitlabClient", gitlabClient);
return context;
},
defaultVNextStreamOptions: (context) => {
console.log("defaultVNextStreamOptions called");
context.runtimeContext.set("gitlabClient", gitlabClient);
return context;
},
tools: {
gitlabGraphQL: gitlabGraphQLTool,
gitlabRest: gitlabRestTool,
},
});
3 Replies
Guria
GuriaOP3w ago
if I delete defaultVNextStreamOptions no other default*Options are called
stdout | src/mastra/index.test.ts > Mastra > Agent.generate() > should generate text response from single message
gitlabAgent.generate

stdout | src/mastra/index.test.ts > Mastra > Agent.generate() > should handle conversation with multiple messages
gitlabAgent.generate

stdout | src/mastra/index.test.ts > Mastra > Agent.stream() > should stream text response in chunks
gitlabAgent.stream

stdout | src/mastra/index.test.ts > Mastra > Agent.stream() > should handle single chunk stream
gitlabAgent.stream
stdout | src/mastra/index.test.ts > Mastra > Agent.generate() > should generate text response from single message
gitlabAgent.generate

stdout | src/mastra/index.test.ts > Mastra > Agent.generate() > should handle conversation with multiple messages
gitlabAgent.generate

stdout | src/mastra/index.test.ts > Mastra > Agent.stream() > should stream text response in chunks
gitlabAgent.stream

stdout | src/mastra/index.test.ts > Mastra > Agent.stream() > should handle single chunk stream
gitlabAgent.stream
Mastra Triager
GitHub
[DISCORD:1424534232977510461] calling default*Options dynamic confi...
This issue was created from Discord post: https://discord.com/channels/1309558646228779139/1424534232977510461 my tests with console.log, that demonstrates that only defaultVNextStreamOptions is ca...
_roamin_
_roamin_3w ago
Hey @Guria ! Yeah, this looks like a bug, you can follow the above PR for updates 😉

Did you find this page helpful?