Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[question] workflow retry 3 times when field of when is false #2773

Closed
JYbill opened this issue Mar 5, 2025 · 1 comment · Fixed by #2794
Closed

[question] workflow retry 3 times when field of when is false #2773

JYbill opened this issue Mar 5, 2025 · 1 comment · Fixed by #2794
Assignees
Labels
bug Something isn't working question Further information is requested Workflows

Comments

@JYbill
Copy link

JYbill commented Mar 5, 2025

  • worflow
import {Step, Workflow} from "@mastra/core/workflows";
import {z} from "zod";

const oneStep = new Step({
  id: "one",
  inputSchema: z.object({
    query: z.string()
  }),
  outputSchema: z.object({
    answer: z.string(),
  }),
  async execute() {
    console.log("one");
    return { answer: "one" };
  }
})


const twoStep = new Step({
  id: "queryAll",
  outputSchema: z.string(),
  async execute() {
    console.log("two")
    return "end";
  }
})

const templateWorkflow = new Workflow({
  name: "poetWorkflow",
  triggerSchema: z.object({
    query: z.string()
  })
})
  .step(oneStep)
  .then(twoStep, {
    when: async () => {
      console.log("false")
      return false;
    }
  })
  .commit()

export { templateWorkflow };


// execution
const { start } = templateWorkflow.createRun();
const res = await start({
  triggerData: { query: "你好" }
});
console.log("d", res.results);
  • output resust
one // ⬅️ oneStep
// ⚠️ start twoStep, but when field always is false
// 🤔 i dont know why need to exec three times? i just wanna to exec once
false
false
false
d {
  one: { status: 'success', output: { answer: 'one' } },
  queryAll: { status: 'failed', error: 'Step:queryAll condition check failed' }
}
  • expect output
one // ⬅️ oneStep
// 💡 twoStep
false
d {
  one: { status: 'success', output: { answer: 'one' } },
  queryAll: { status: 'failed', error: 'Step:queryAll condition check failed' }
}
@github-actions github-actions bot added bug Something isn't working question Further information is requested Workflows labels Mar 5, 2025
@linear linear bot assigned adeniyii Mar 5, 2025
@adeniyii
Copy link
Contributor

adeniyii commented Mar 5, 2025

Good catch.
We shouldn't be retrying steps multiple times unless specifically configured.
We'll update, thanks for bringing this up!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested Workflows
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants