Skip to content

[FEAT] Add tool suspend/resume functionality similar to Mastra #1194

@lusons

Description

@lusons

Is your feature request related to a problem? Please describe.

Since Mastra offers a similar feature, it would be great if Voltagent could support this as well. From my experience, I can easily implement a similar AskUserTool.

Describe alternatives you've considered

No response

Additional context

No response

Describe the thing to improve

I hope Voltagent can support a similar usage, or does the team have a better solution?

export const testToolB = createTool({
  id: 'test-tool-b',
  description: 'Fetches weather for a location',
  inputSchema: z.object({
    location: z.string(),
  }),
  outputSchema: z.object({
    weather: z.string(),
  }),
  resumeSchema: z.object({
    approved: z.boolean(),
  }),
  suspendSchema: z.object({
    reason: z.string(),
  }),
  execute: async (inputData, context) => {
    const { resumeData: { approved } = {}, suspend } = context?.agent ?? {}

    if (!approved) {
      return suspend?.({ reason: 'Approval required.' })
    }

    const response = await fetch(`https://wttr.in/${inputData.location}?format=3`)
    const weather = await response.text()

    return { weather }
  },
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions