Skip to content

fix: delegate get input to orchestrator tool#132

Merged
haifeng-li-at-salesforce merged 11 commits intoforcedotcom:mainfrom
haifeng-li-at-salesforce:simpleGetInput
Jan 20, 2026
Merged

fix: delegate get input to orchestrator tool#132
haifeng-li-at-salesforce merged 11 commits intoforcedotcom:mainfrom
haifeng-li-at-salesforce:simpleGetInput

Conversation

@haifeng-li-at-salesforce
Copy link
Contributor

Changes

  • Adds support for delegating getInput calls to the orchestrator tool
  • Updates the orchestrator tool to handle getInput requests
  • Adds metadata support for input delegation
  • Includes corresponding tests and documentation updates

Files Changed

  • `docs/9_mcp_workflow_engine_extraction/design.md` - Documentation updates
  • `packages/mcp-workflow/src/common/metadata.ts` - Metadata type additions
  • `packages/mcp-workflow/src/services/getInputService.ts` - Service updates
  • `packages/mcp-workflow/src/tools/orchestrator/metadata.ts` - Orchestrator metadata
  • `packages/mcp-workflow/src/tools/orchestrator/orchestratorTool.ts` - Main implementation
  • `packages/mcp-workflow/tests/services/getInputService.test.ts` - Service tests
  • `packages/mcp-workflow/tests/tools/orchestrator/orchestratorTool.test.ts` - Orchestrator tests"

What issues does this PR fix or reference?

it fixes the getInput off-trail issues

@haifeng-li-at-salesforce haifeng-li-at-salesforce requested a review from a team as a code owner January 13, 2026 19:47
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have you considered rather than embedding input logic in the orchestrator, keeping it in the node itself?

here is a spike I did on "Guidance-only" nodes - it might be a bit verbose but the idea is still encapsulating the guidance within the responsible node rather than have the orchestrator be responsible for everything

jhorst11@265265c#diff-26a7cf13d2b4b7ead6b447baa60686a300769ec0ad50a81d81c36ee4d7a70c5d

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we'll want to replicate the pattern of direct-guidance nodes beyond just input so I'm hestitant to embed this logic directly into the orchestrator tool

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Totally agree. Overloading the orchestrator tool is not a good idea. This logic should live at the node level so it can be applied consistently across all nodes in the future. I’m thinking each node could support two modes: a direct guidance mode and a tool delegation mode.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The following changes have been implemented:

  • Added a direct guidance mode alongside the existing delegation mode. In direct guidance mode, the guidances are handled directly by the orchestrator.

  • Introduced NodeGuidanceData for direct guidance mode, serving as the counterpart to MCPToolInvocationData.

  • Added an exampleOutput field to NodeGuidanceData to improve LLM compliance and response consistency.

@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 95.19231% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.29%. Comparing base (e87d017) to head (6e90fe0).

Files with missing lines Patch % Lines
...orkflow/src/tools/orchestrator/orchestratorTool.ts 89.13% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #132      +/-   ##
==========================================
+ Coverage   88.25%   88.29%   +0.04%     
==========================================
  Files         165      165              
  Lines        7059     7119      +60     
  Branches      994      981      -13     
==========================================
+ Hits         6230     6286      +56     
- Misses        829      833       +4     
Flag Coverage Δ
evaluation 80.14% <ø> (ø)
monorepo 88.29% <95.19%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

You are participating in a workflow orchestration process. The orchestrator is providing
you with direct guidance for the current task.

# TASK GUIDANCE
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless there's specific evaluation that suggests the guidance should come first, I'd prefer that we put INPUT SCHEMA and INPUT DATA before TASK GUIDANCE. It's typical practice to put the context section of a prompt earlier than the guidance itself, so that the LLM doesn't have to "go backwards" and reconsider semantics it already considered, through the lens of the "new info" that is its inputs. It just simplifies the logical processing of the semantics of the prompt.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The INPUT SCHEMA and INPUT DATA sections are removed from createDirectGuidancePrompt to reduce token usage without losing any functional information, since generateTaskGuidance is designed to be self-contained and already includes all the context the LLM needs. The test result looks solid.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are not removed at the moment—they are 4 lines down from here. :) My suggestion here was just to define them before the TASK GUIDANCE section, instead of after.

Copy link
Contributor Author

@haifeng-li-at-salesforce haifeng-li-at-salesforce Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure what happens. But it is removed in my branch

I understand your suggestions. However, after further investigation, it turns out that both INPUT_SCHEMA and INPUT_DATA are redundant.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand why the changes aren’t visible. In the top-left selection box, choose “Changes from all commits” to see the latest updates.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, got it. I don't disagree that I think we can live without it. I was just confused because it still seemed to be there. Seems fine in the latest version.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not clear on the design pattern here. Why are we delegating the initiation of guidance creation to the orchestrator? What part is it meant to play in owning that process? Why would we not simply seed NodeGuidanceData.taskGuidance with each node's expression of guidance.

This data structure is making a round trip back to the node that's responsible for generating guidance anyway. I'm not seeing the value in that process.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, we're not even delegating responsibility to the orchestrator: we're just delegating our node class's API to a different data structure. That doesn't pass muster to me. I don't actually see value in codifying the way that nodes create guidance. I think each node can be left to its own devices as to how it needs to formulate the guidance it sends along. There is no value that I can see in a shared commonality here.

Copy link
Contributor Author

@haifeng-li-at-salesforce haifeng-li-at-salesforce Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The data flow is as following:

  1. Service (e.g., GetInputService) calls metadata.generateTaskGuidance!(input) to get the guidance string

  2. Service populates NodeGuidanceData.taskGuidance with that string

  3. Service calls interrupt(nodeGuidanceData) - sending everything to the orchestrator

  4. Orchestrator receives the pre-populated NodeGuidanceData and wraps it with workflow continuation instructions via createDirectGuidancePrompt()

The orchestrator simply reads taskGuidance from the interrupt data - it doesn't generate it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The generateTaskGuidance function exists as a single source of truth for guidance generation that can be used by both execution modes:

  • Direct Guidance Mode (via Services): The service calls metadata.generateTaskGuidance() and populates NodeGuidanceData.taskGuidance before interrupting

  • Delegate Mode (via Tools): When the tool is invoked as a separate MCP tool, it calls metadata.generateTaskGuidance() directly:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once all remaining delegated tools (five in total) are removed, we can replace WorkflowToolMetadata with NodeGuidanceMetadata, which will live in the Node/Service.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The generateTaskGuidance function exists as a single source of truth for guidance generation that can be used by both execution modes:

My argument is that it doesn't serve sufficient purpose to create such an abstraction. The creation of guidance lives pretty concretely with the code base that implements a given agent, be it a node, service, or MCP tool. These agentic foundations are mutually exclusive from each other, which is the only scenario I could think of where we may want to consolidate this guidance.

And the reason that I'm looking for a justification of it, is to offset the penalty for the implementation: a code maintainer has to follow code around through a few different passage points to find the source of this guidance, when logically speaking you'd expect to find it "close to" the agent code base that defines it.

I think it's telling that we're not implementing this all across our existing nodes, services, and MCP tools as part of this refactor, and yet the sky is not falling from failing to do so. This to me is an abstraction that does not benefit the code base—only obfuscates it unnecessarily.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes total sense. I agree that the recommendation is much more intuitive; my current implementation is a bit counter-intuitive. I’ll refactor the code to move guidance creation from tool metadata into the Agent class (node/service). This change will apply specifically to the get Input and extract input services.

Copy link
Contributor Author

@haifeng-li-at-salesforce haifeng-li-at-salesforce Jan 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@khawkins The following code changes have been made. Please take another look and let me know your thoughts. Thanks!

  1. Moving guidance generation logic from metadata classes into the services themselves (InputExtractionService and GetInputService)
  2. Simplifying the architecture - the metadata.ts base class no longer has tool-specific functions; guidance generation is now handled directly by the services

Copy link
Collaborator

@khawkins khawkins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great overall! I'd like to answer the questions around generateTaskGuidance and the minor one around the ordering in the direct guidance prompt in the orchestrator. But I think overall this is solid.

…nctions from metadata class and consolidating logic in InputExtractionService and GetInputService
Copy link
Collaborator

@khawkins khawkins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me!

@haifeng-li-at-salesforce haifeng-li-at-salesforce merged commit 79eb1bd into forcedotcom:main Jan 20, 2026
9 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

Comments