Skip to content

Minimal DI for workflow nodes via node_factory constructor injection #30506

@laipz8200

Description

@laipz8200
  • I have read the Contributing Guide and Language Policy.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • Please do not modify this template :) and fill in all the required fields.

1. Is this request related to a challenge you're experiencing? Tell me about your story.

I’m building workflow-based apps where nodes depend on services like HTTP clients, memory systems, and RAG/retrieval. Right now those dependencies are effectively fixed or global, so swapping implementations per workflow/app is difficult and testing nodes requires patching globals. I want a simple injection mechanism so nodes can receive dependencies explicitly and I can choose implementations per workflow without forking nodes or adding ad‑hoc conditionals.

2. Additional context or comments

Proposal (minimal DI approach):

  • Use constructor injection for node dependencies (e.g., HttpClient, MemoryStore, RagRetriever).
  • Update node_factory to resolve and pass these dependencies when instantiating nodes.
  • Keep default behavior unchanged by providing default implementations in node_factory if no overrides are configured.
  • Allow configuration (initially internal) to choose alternative implementations per workflow/app/run.
  • Focus on a small set of core dependencies first (HTTP client + memory + RAG), expand later.

Acceptance criteria (minimal scope):

  • Existing workflows continue to run without config changes.
  • Nodes can declare dependencies in their constructor.
  • node_factory injects defaults or configured implementations.
  • Unit tests for node instantiation + dependency resolution paths.

Notes:

  • This keeps DI centralized and avoids a heavy framework; it’s a targeted change to node_factory plus constructor signatures.

3. Can you help us with this feature?

  • I am interested in contributing to this feature.

Sub-issues

Metadata

Metadata

Assignees

Labels

staleIssue has not had recent activity or appears to be solved. Stale issues will be automatically closed💪 enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions