diff --git a/control-plane/internal/handlers/execute.go b/control-plane/internal/handlers/execute.go index f3a45c09..5c5b3431 100644 --- a/control-plane/internal/handlers/execute.go +++ b/control-plane/internal/handlers/execute.go @@ -540,11 +540,15 @@ func (c *executionController) handleStatusUpdate(ctx *gin.Context) { } } - c.publishExecutionEvent(updated, normalizedStatus, map[string]interface{}{ + eventData := map[string]interface{}{ "result": req.Result, "error": req.Error, "progress": req.Progress, - }) + } + if inputPayload := decodeJSON(updated.InputPayload); inputPayload != nil { + eventData["input"] = inputPayload + } + c.publishExecutionEvent(updated, normalizedStatus, eventData) ctx.JSON(http.StatusOK, renderStatus(updated)) } @@ -993,6 +997,9 @@ func (c *executionController) completeExecution(ctx context.Context, plan *prepa if payload := decodeJSON(result); payload != nil { eventData["result"] = payload } + if inputPayload := decodeJSON(plan.exec.InputPayload); inputPayload != nil { + eventData["input"] = inputPayload + } c.publishExecutionEventWithReasonerInfo(updated, string(types.ExecutionStatusSucceeded), eventData, plan.agent, &plan.target.TargetName) return nil } @@ -1046,6 +1053,9 @@ func (c *executionController) failExecution(ctx context.Context, plan *preparedE if payload := decodeJSON(result); payload != nil { eventData["result"] = payload } + if inputPayload := decodeJSON(plan.exec.InputPayload); inputPayload != nil { + eventData["input"] = inputPayload + } c.publishExecutionEventWithReasonerInfo(updated, string(types.ExecutionStatusFailed), eventData, plan.agent, &plan.target.TargetName) return nil } diff --git a/examples/ts-node-examples/init-example/reasoners.ts b/examples/ts-node-examples/init-example/reasoners.ts index 745339bf..b622cee5 100644 --- a/examples/ts-node-examples/init-example/reasoners.ts +++ b/examples/ts-node-examples/init-example/reasoners.ts @@ -31,6 +31,10 @@ const sentimentSchema = z.object({ }); type SentimentResult = z.infer; +const analyzeSentimentOutputSchema = sentimentSchema.extend({ + text: z.string() +}); + reasonersRouter.reasoner<{ text: string }, SentimentResult & { text: string }>( 'analyzeSentiment', async (ctx) => { @@ -73,9 +77,15 @@ reasonersRouter.reasoner<{ text: string }, SentimentResult & { text: string }>( }); return { ...sentiment, text: ctx.input.text }; - } + }, + { outputSchema: analyzeSentimentOutputSchema } ); +const processWithNotesOutputSchema = z.object({ + processed: z.number(), + notes: z.number() +}); + reasonersRouter.reasoner<{ items: string[] }, { processed: number; notes: number }>( 'processWithNotes', async (ctx) => { @@ -109,5 +119,6 @@ reasonersRouter.reasoner<{ items: string[] }, { processed: number; notes: number processed: processed.length, notes: notesSent }; - } + }, + { outputSchema: processWithNotesOutputSchema } ); \ No newline at end of file