Skip to content

feat(engine): sequential workflow executor core (closes #22)#56

Merged
leo-aa88 merged 1 commit into
mainfrom
issue/22-workflow-engine
Apr 12, 2026
Merged

feat(engine): sequential workflow executor core (closes #22)#56
leo-aa88 merged 1 commit into
mainfrom
issue/22-workflow-engine

Conversation

@leo-aa88
Copy link
Copy Markdown
Member

Summary

Implements the sequential workflow execution engine from issue #22 and design doc sections 12.2 E, 13.3, 13.4, and 14.2: run workflows step-by-step with interpolation, policy, tools, agents, schema validation, and persistence.

New files (as scoped)

File Purpose
execution.go Executor, RunInput, Run orchestration
workflow.go Workflow lookup, optional workflow input JSON Schema, workflow output interpolation
steps.go Tool and agent step execution, agent output schema validation
timeout.go Per-agent-step context.WithTimeout from Agent.constraints.timeoutSeconds
retries.go Single retry when model errors wrap ErrTransientGeneration

Behavior

  • Steps: exactly one of uses (tool) or agent per step; native/MCP/HTTP/mock tools go through tools.ToolExecutor; agents use models.ModelClient (registry or ModelResolve for tests).
  • Interpolation: existing InterpolateWalk on each steps with` map.
  • Policy: policy.Engine.Evaluator for the workflows spec.policy` name (budgets, structured output, tools, approvals).
  • Agent prompt (MVP): system message = agent instructions; user message = JSON-marshaled with map.
  • Agent output: response body must be a JSON object; if agent.spec.output.schema is set, schema.Validate runs (hard fail on invalid instance).
  • Persistence: expects an existing runs row; updates run_steps, FinishRun, optional trace.Recorder (step.*, tool.*, model.*).
  • Tool retries: unchanged — still driven by tool spec.retry inside MCP/HTTP runtimes.

Tests

  • Integration: multi-step workflow — native echo tool then mock model agent; asserts final run output_json and trace events.
  • Schema: agent returns JSON missing required summary; run ends failed.
  • Retry helper: withAgentRetry invokes fn twice on transient error.

Verification

  • make fmt
  • make vet
  • make test (-race)

Follow-ups (out of scope for #22)

  • Wire agentctl run CLI, parallelism, conditionals, environment policy merge.
  • Richer transient-error detection for real providers.

Closes #22

Made with Cursor

- Add Executor.Run: sequential steps, interpolate with, workflow Policy
  checks, tool vs agent dispatch, agent JSON Schema validation
- Persist run_steps and trace (step/tool/model events)
- timeout.go: agent step timeout from Agent constraints
- retries.go: one MVP retry for ErrTransientGeneration model errors
- workflow.go: lookup workflow, validate workflow input schema, build output
- steps.go: tool and agent step runners (mock model + native tool tests)

Closes #22

Made-with: Cursor
@leo-aa88 leo-aa88 merged commit e0a2536 into main Apr 12, 2026
4 checks passed
@leo-aa88 leo-aa88 deleted the issue/22-workflow-engine branch April 12, 2026 01:15
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.

[MVP] Sequential workflow engine core (internal/engine)

1 participant