Skip to content

Commit b24e922

Browse files
committed
feat: Remove unnecessary workflow state reset calls; streamline workflow execution logic for improved clarity
1 parent 4720488 commit b24e922

File tree

3 files changed

+7
-25
lines changed

3 files changed

+7
-25
lines changed

packages/core/src/executors/sampling/workflow-sampling-executor.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,6 @@ export class WorkflowSamplingExecutor extends BaseSamplingExecutor {
8686

8787
const toolCallData = parsedData as Record<string, unknown>;
8888

89-
if (toolCallData.userRequest) {
90-
workflowState.reset();
91-
}
92-
9389
if (toolCallData.action === "complete") {
9490
const reasoning = (toolCallData.reasoning as string) || "Task completed";
9591
return this.createCompletionResult(reasoning);

packages/core/src/executors/workflow/workflow-tool-registrar.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ export function registerAgenticWorkflowTool(
8686
try {
8787
// Use appropriate executor based on mode
8888
if (sampling) {
89-
workflowState.reset();
9089
return await workflowSamplingExecutor.executeWorkflowSampling(
9190
args as Record<string, unknown>,
9291
argsDef as Record<string, unknown>,

packages/core/src/factories/args-def-factory.ts

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -101,27 +101,14 @@ Workflow step definitions - provide ONLY on initial call.
101101
},
102102

103103
forCurrentState: function (state: WorkflowState): JSONSchema {
104-
if (!state.isWorkflowInitialized()) {
105-
if (predefinedSteps) {
106-
return this.common({
107-
init: this.init(),
108-
});
109-
}
110-
return this.common({
111-
steps: this.steps(),
112-
init: this.init(),
113-
});
114-
}
115-
116104
const currentStep = state.getCurrentStep();
117-
if (!currentStep) {
118-
throw new Error(
119-
`Invalid workflow state: no current step, ${
120-
JSON.stringify(
121-
state.getDebugInfo(),
122-
)
123-
}`,
124-
);
105+
if (!state.isWorkflowInitialized() || !currentStep) {
106+
state.reset();
107+
const initSchema: Record<string, JSONSchema> = { init: this.init() };
108+
if (!predefinedSteps) {
109+
initSchema.steps = this.steps();
110+
}
111+
return this.common(initSchema);
125112
}
126113

127114
const stepDependencies = {

0 commit comments

Comments
 (0)