First-class NestJS support for DurableAgent tool execution
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 2.4k
- Forks
- 365
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 169
Description
Context
I am integrating Workflow SDK into a NestJS service. @workflow/nest gets the basic routing/build integration working (WorkflowModule.forRoot, generated .nestjs/workflow bundles, .well-known/workflow/v1 handlers), but the hardest part is using DurableAgent / AI SDK tools with Nest-native implementations.
In our app, tools need to be declared at the workflow level because they are passed into DurableAgent. That means the workflow bundle needs workflow-safe tool objects: names, schemas, descriptions, and execute placeholders that can be transformed into workflow steps. But the real implementations live behind Nest providers and need DI, auth/request context, stream writers, tokens, database/file services, etc.
To make this work today, we are building thin workflow-safe wrappers that avoid importing decorated Nest providers into the workflow bundle, then resolve a ModuleRef/global dependency bridge inside the step execution path. This works, but it is fragile and feels like something the framework integration should own.
What is difficult today
- Tool definitions are tied to
DurableAgent, so they naturally live in the workflow bundle. - Concrete Nest tool factories/providers often cannot be imported safely into that bundle.
- Each durable tool needs a small
"use step"wrapper that calls back into Nest DI. - Passing auth context, user/account context, graph tokens, stream writers, and provider tokens is all manual.
- It is unclear whether the right extension point should be SWC, codegen in
@workflow/nest, or a runtime bridge API.
Request
Would the Workflow team consider first-class support, or at least a recommended pattern, for NestJS-backed DurableAgent tools?
The shape I am hoping for is something like:
- Define tool/step mappings in a Nest module or provider.
- Keep tool metadata workflow-safe.
- Generate or expose workflow-safe
"use step"wrappers forDurableAgenttools. - Execute the real implementation through Nest DI at step runtime.
- Provide a documented pattern for request/auth context and streaming output.
For example, a future integration might let users write something conceptually like:
@Injectable()
class MyWorkflowTools {
@WorkflowTool("processFiles")
async processFiles(input, context) {
// normal Nest DI works here
}
}
and have @workflow/nest / SWC / codegen produce the workflow-safe tool/step bridge that DurableAgent can consume.
Questions
- Is there an intended way to connect
DurableAgenttools to Nest DI beyond a manualModuleRefbridge? - Are generated exported step wrappers the right direction, or is this something SWC should understand natively?
- Would a contribution in
@workflow/nestfor this kind of bridge be welcome?
Happy to provide more detail or test an API shape if helpful.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the existing @workflow/nest integration, including WorkflowModule.forRoot, generated .nestjs/workflow bundles, and the DurableAgent tool execution path. Review the current manual ModuleRef bridge and the possible SWC or codegen extension points. Done would be a decided, documented pattern or supported bridge for Nest DI, workflow-safe tool metadata, runtime context, and streaming output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- backend, developer-experience
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 28/100