Skip to content

Commit 6e15840

Browse files
alban bertoliniclaude
andcommitted
refactor(workflow-executor): rename history to previousSteps and document executionResult
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent f689b33 commit 6e15840

7 files changed

Lines changed: 21 additions & 20 deletions

File tree

packages/workflow-executor/src/executors/base-step-executor.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export default abstract class BaseStepExecutor<TStep extends StepDefinition = St
3636
* Empty array when there is no history. Ready to spread into a messages array.
3737
*/
3838
protected async buildPreviousStepsMessages(): Promise<SystemMessage[]> {
39-
if (!this.context.history.length) return [];
39+
if (!this.context.previousSteps.length) return [];
4040

4141
const summary = await this.summarizePreviousSteps();
4242

@@ -52,7 +52,7 @@ export default abstract class BaseStepExecutor<TStep extends StepDefinition = St
5252
private async summarizePreviousSteps(): Promise<string> {
5353
const allStepExecutions = await this.context.runStore.getStepExecutions();
5454

55-
return this.context.history
55+
return this.context.previousSteps
5656
.map(({ stepDefinition, stepOutcome }) => {
5757
const execution = allStepExecutions.find(e => e.stepIndex === stepOutcome.stepIndex);
5858

packages/workflow-executor/src/types/execution.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export interface ExecutionContext<TStep extends StepDefinition = StepDefinition>
3939
readonly agentPort: AgentPort;
4040
readonly workflowPort: WorkflowPort;
4141
readonly runStore: RunStore;
42-
readonly history: ReadonlyArray<Readonly<Step>>;
42+
readonly previousSteps: ReadonlyArray<Readonly<Step>>;
4343
readonly remoteTools: readonly unknown[];
4444
readonly userInput?: UserInput;
4545
}

packages/workflow-executor/src/types/step-execution-data.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export interface ReadRecordStepExecutionData extends BaseStepExecutionData {
4545
export interface UpdateRecordStepExecutionData extends BaseStepExecutionData {
4646
type: 'update-record';
4747
executionParams?: { fieldDisplayName: string; value: string };
48+
/** User confirmed → values returned by updateRecord. User rejected → skipped. */
4849
executionResult?: { updatedValues: Record<string, unknown> } | { skipped: true };
4950
pendingUpdate?: {
5051
fieldDisplayName: string;

packages/workflow-executor/test/executors/base-step-executor.test.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ function makeContext(overrides: Partial<ExecutionContext> = {}): ExecutionContex
7373
agentPort: {} as ExecutionContext['agentPort'],
7474
workflowPort: {} as ExecutionContext['workflowPort'],
7575
runStore: makeMockRunStore(),
76-
history: [],
76+
previousSteps: [],
7777
remoteTools: [],
7878
...overrides,
7979
};
@@ -90,7 +90,7 @@ describe('BaseStepExecutor', () => {
9090
it('includes prompt and executionParams from previous steps', async () => {
9191
const executor = new TestableExecutor(
9292
makeContext({
93-
history: [makeHistoryEntry({ stepId: 'cond-1', stepIndex: 0, prompt: 'Approve?' })],
93+
previousSteps: [makeHistoryEntry({ stepId: 'cond-1', stepIndex: 0, prompt: 'Approve?' })],
9494
runStore: makeMockRunStore([
9595
{
9696
type: 'condition',
@@ -115,7 +115,7 @@ describe('BaseStepExecutor', () => {
115115
it('uses Input for matched steps and History for unmatched steps', async () => {
116116
const executor = new TestableExecutor(
117117
makeContext({
118-
history: [
118+
previousSteps: [
119119
makeHistoryEntry({ stepId: 'cond-1', stepIndex: 0 }),
120120
makeHistoryEntry({ stepId: 'cond-2', stepIndex: 1, prompt: 'Second?' }),
121121
],
@@ -145,7 +145,7 @@ describe('BaseStepExecutor', () => {
145145
it('falls back to History when no matching step execution in RunStore', async () => {
146146
const executor = new TestableExecutor(
147147
makeContext({
148-
history: [
148+
previousSteps: [
149149
makeHistoryEntry({ stepId: 'orphan', stepIndex: 5, prompt: 'Orphan step' }),
150150
makeHistoryEntry({ stepId: 'matched', stepIndex: 1, prompt: 'Matched step' }),
151151
],
@@ -181,7 +181,7 @@ describe('BaseStepExecutor', () => {
181181

182182
const executor = new TestableExecutor(
183183
makeContext({
184-
history: [entry],
184+
previousSteps: [entry],
185185
runStore: makeMockRunStore([]),
186186
}),
187187
);
@@ -205,7 +205,7 @@ describe('BaseStepExecutor', () => {
205205

206206
const executor = new TestableExecutor(
207207
makeContext({
208-
history: [entry],
208+
previousSteps: [entry],
209209
runStore: makeMockRunStore([]),
210210
}),
211211
);
@@ -234,7 +234,7 @@ describe('BaseStepExecutor', () => {
234234

235235
const executor = new TestableExecutor(
236236
makeContext({
237-
history: [entry],
237+
previousSteps: [entry],
238238
runStore: makeMockRunStore([]),
239239
}),
240240
);
@@ -270,7 +270,7 @@ describe('BaseStepExecutor', () => {
270270

271271
const executor = new TestableExecutor(
272272
makeContext({
273-
history: [condEntry, aiEntry],
273+
previousSteps: [condEntry, aiEntry],
274274
runStore: makeMockRunStore([
275275
{
276276
type: 'ai-task',
@@ -297,7 +297,7 @@ describe('BaseStepExecutor', () => {
297297

298298
const executor = new TestableExecutor(
299299
makeContext({
300-
history: [entry],
300+
previousSteps: [entry],
301301
runStore: makeMockRunStore([
302302
{
303303
type: 'condition',
@@ -334,7 +334,7 @@ describe('BaseStepExecutor', () => {
334334

335335
const executor = new TestableExecutor(
336336
makeContext({
337-
history: [entry],
337+
previousSteps: [entry],
338338
runStore: makeMockRunStore([
339339
{
340340
type: 'ai-task',
@@ -359,7 +359,7 @@ describe('BaseStepExecutor', () => {
359359

360360
const executor = new TestableExecutor(
361361
makeContext({
362-
history: [entry],
362+
previousSteps: [entry],
363363
runStore: makeMockRunStore([
364364
{
365365
type: 'condition',

packages/workflow-executor/test/executors/condition-step-executor.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ function makeContext(
5353
agentPort: {} as ExecutionContext['agentPort'],
5454
workflowPort: {} as ExecutionContext['workflowPort'],
5555
runStore: makeMockRunStore(),
56-
history: [],
56+
previousSteps: [],
5757
remoteTools: [],
5858
...overrides,
5959
};
@@ -175,7 +175,7 @@ describe('ConditionStepExecutor', () => {
175175
const context = makeContext({
176176
model: mockModel.model,
177177
runStore,
178-
history: [
178+
previousSteps: [
179179
{
180180
stepDefinition: {
181181
type: StepType.Condition,

packages/workflow-executor/test/executors/read-record-step-executor.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ function makeContext(
111111
agentPort: makeMockAgentPort(),
112112
workflowPort: makeMockWorkflowPort(),
113113
runStore: makeMockRunStore(),
114-
history: [],
114+
previousSteps: [],
115115
remoteTools: [],
116116
...overrides,
117117
};
@@ -650,7 +650,7 @@ describe('ReadRecordStepExecutor', () => {
650650
const context = makeContext({
651651
model: mockModel.model,
652652
runStore,
653-
history: [
653+
previousSteps: [
654654
{
655655
stepDefinition: {
656656
type: StepType.Condition,

packages/workflow-executor/test/executors/update-record-step-executor.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ function makeContext(
112112
agentPort: makeMockAgentPort(),
113113
workflowPort: makeMockWorkflowPort(),
114114
runStore: makeMockRunStore(),
115-
history: [],
115+
previousSteps: [],
116116
remoteTools: [],
117117
...overrides,
118118
};
@@ -620,7 +620,7 @@ describe('UpdateRecordStepExecutor', () => {
620620
const context = makeContext({
621621
model: mockModel.model,
622622
runStore,
623-
history: [
623+
previousSteps: [
624624
{
625625
stepDefinition: {
626626
type: StepType.Condition,

0 commit comments

Comments
 (0)