Examples & Patterns
Real-world examples from simple tasks to complex multi-stage workflows.
Simple Research Task
BeginnerSingle Agent
A straightforward procedure that researches a topic and returns findings.
name: simple_researcher version: 1.0.0 params: topic: type: string required: true outputs: summary: type: string required: true agents: researcher: system_prompt: | Research: {params.topic} Use search tool, provide summary. tools: [search, done] max_turns: 10 return_prompt: | Provide research summary. workflow: | repeat Researcher.turn() until Tool.called("done") or Iterations.exceeded(10) return { summary = State.get("summary") or "No summary" }
Content Pipeline with HITL
IntermediateHITLMulti-Stage
Generate content, review with human, and publish with approval.
name: content_pipeline version: 1.0.0 params: topic: type: string required: true outputs: published: type: boolean required: true stages: - drafting - review - publishing hitl: review_content: type: review message: "Review content" timeout: 86400 confirm_publish: type: approval message: "Publish?" timeout: 3600 agents: writer: system_prompt: "Write about: {params.topic}" tools: [research, write, done] workflow: | -- Generate Stage.set("drafting") Human.notify({message = "Generating content"}) repeat Writer.turn() until Tool.called("done") -- Human review Stage.set("review") local review = Human.review("review_content", { artifact = State.get("draft") }) if review.decision == "reject" then return {published = false} end -- Publish Stage.set("publishing") local approved = Human.approve("confirm_publish") if approved then publish(review.edited_artifact or State.get("draft")) return {published = true} else return {published = false} end
Parallel Research
IntermediateAsyncParallel
Research multiple topics in parallel and aggregate results.
name: parallel_researcher version: 1.0.0 params: topics: type: array required: true outputs: results: type: array required: true procedures: researcher: params: topic: type: string required: true outputs: findings: type: string required: true agents: worker: system_prompt: "Research: {params.topic}" tools: [search, done] workflow: | repeat Worker.turn() until Tool.called("done") return {findings = State.get("findings")} workflow: | -- Spawn researchers in parallel local handles = {} for _, topic in ipairs(params.topics) do local handle = Procedure.spawn("researcher", { topic = topic }) table.insert(handles, handle) end -- Wait for all Procedure.wait_all(handles) -- Collect results local results = {} for _, handle in ipairs(handles) do local result = Procedure.result(handle) table.insert(results, result) end return {results = results}
Deployment Pipeline
AdvancedHITLMulti-Stage
Complete deployment pipeline with verification and rollback.
name: deployment_pipeline version: 1.0.0 params: version: type: string required: true environment: type: string enum: [staging, production] required: true outputs: deployed: type: boolean required: true stages: - preparing - testing - approval - deploying - verifying hitl: approve_deployment: type: approval message: "Deploy {params.version} to {params.environment}?" timeout: 1800 approve_rollback: type: approval message: "Verification failed. Rollback?" timeout: 600 default: true workflow: | -- Prepare Stage.set("preparing") Human.notify({message = "Preparing deployment"}) local build_ok = build_artifacts(params.version) if not build_ok then System.alert({ message = "Build failed", level = "error", source = "deployment_pipeline" }) return {deployed = false} end -- Test Stage.set("testing") local tests_ok = run_tests() if not tests_ok then return {deployed = false} end -- Approval Stage.set("approval") local approved = Human.approve("approve_deployment", { context = { version = params.version, risk_level = params.environment == "production" and "high" or "medium" } }) if not approved then return {deployed = false} end -- Deploy Stage.set("deploying") local deploy_ok, url = deploy(params.version, params.environment) if not deploy_ok then System.alert({ message = "Deployment failed", level = "critical", source = "deployment_pipeline" }) return {deployed = false} end -- Verify Stage.set("verifying") Sleep(30) local verify_ok = verify_deployment(url) if not verify_ok then local rollback = Human.approve("approve_rollback") if rollback then rollback_deployment(params.environment) return {deployed = false} end end Human.notify({message = "Deployment successful"}) return {deployed = true}
More Examples
Complete HTML documentation with 8 detailed examples is available at:
/plexus/procedures/docs/examples.htmlIncludes examples for: data processing, recursive task decomposition, batch processing with monitoring, and multi-agent workflows.