diff --git a/packages/core/src/context/ir/toIr.ts b/packages/core/src/context/ir/toIr.ts index ed0adc61c4..472a6bf8b0 100644 --- a/packages/core/src/context/ir/toIr.ts +++ b/packages/core/src/context/ir/toIr.ts @@ -39,8 +39,8 @@ function isCompleteEpisode(ep: Partial): ep is Episode { return ( typeof ep.id === 'string' && typeof ep.timestamp === 'number' && - !!ep.trigger && - Array.isArray(ep.steps) + Array.isArray(ep.children) && + ep.children.length > 0 ); } @@ -120,14 +120,14 @@ function parseToolResponses( currentEpisode = { id: getStableId(msg), timestamp: Date.now(), - trigger: { + children: [{ id: getStableId(msg.parts![0] || msg), type: 'SYSTEM_EVENT', name: 'history_resume', payload: {}, metadata: createMetadata([]), - } as SystemEvent, - steps: [], + }, + ], }; } @@ -161,7 +161,7 @@ function parseToolResponses( transformations: [], }, }; - currentEpisode.steps!.push(step); + currentEpisode.children!.push(step); if (callId) pendingCallParts.delete(callId); } } @@ -203,8 +203,7 @@ function parseUserParts( type: 'EPISODE', id: getStableId(msg), timestamp: Date.now(), - trigger, - steps: [], + children: [trigger], }; } @@ -218,14 +217,14 @@ function parseModelParts( currentEpisode = { id: getStableId(msg), timestamp: Date.now(), - trigger: { + children: [{ id: getStableId(msg.parts![0] || msg), type: 'SYSTEM_EVENT', name: 'model_init', payload: {}, metadata: createMetadata([]), - } as SystemEvent, - steps: [], + }, + ], }; } @@ -240,15 +239,15 @@ function parseModelParts( text: part.text, metadata: createMetadata([part]), }; - currentEpisode.steps!.push(thought); + currentEpisode.children!.push(thought); } } return currentEpisode; } function finalizeYield(currentEpisode: Partial) { - if (currentEpisode.steps && currentEpisode.steps.length > 0) { - const lastStep = currentEpisode.steps[currentEpisode.steps.length - 1]; + if (currentEpisode.children && currentEpisode.children.length > 0) { + const lastStep = currentEpisode.children[currentEpisode.children.length - 1]; if (isAgentThought(lastStep)) { const yieldNode: AgentYield = { id: lastStep.id, @@ -256,8 +255,8 @@ function finalizeYield(currentEpisode: Partial) { text: lastStep.text, metadata: lastStep.metadata, }; - currentEpisode.steps.pop(); - currentEpisode.yield = yieldNode; + currentEpisode.children.pop(); + currentEpisode.children.push(yieldNode); } } } diff --git a/packages/core/src/context/sidecar/orchestrator.ts b/packages/core/src/context/sidecar/orchestrator.ts index 1f75a935d3..faaf6e7596 100644 --- a/packages/core/src/context/sidecar/orchestrator.ts +++ b/packages/core/src/context/sidecar/orchestrator.ts @@ -35,7 +35,7 @@ export class PipelineOrchestrator { for (const procDef of pipeline.processors) { if (!this.instantiatedProcessors.has(procDef.processorId)) { const factory = this.registry.get(procDef.processorId); - const instance = factory.create(this.env, procDef.options); + const instance = factory.create(this.env, procDef.options || {}); this.instantiatedProcessors.set(procDef.processorId, instance); } }