Документация

Workflow & Orchestration Tools

Workflow state machines, context handoff, code execution, and feedback

Workflow state machines, context handoff, code execution, and feedback

These tools manage multi-step workflows with state machines, enable context handoff between sessions, execute code in sandboxed environments, and collect quality feedback for continuous improvement.

Tools Overview

ToolWhat It Does
ctx_workflow Workflow rails (state machine + evidence). Actions: start|status|transition|complete|evidence_add|evidence_list|stop.
ctx_handoff Context Ledger Protocol (hashed, deterministic, local-first). Actions: create|show|list|pull|clear.
ctx_execute Run code in sandbox (11 languages). Only stdout enters context. Raw data never leaves subprocess. Languages: javascript, typescript, python, shell, ruby, go, rust, php, perl, r, elixir.
ctx_feedback Harness feedback for LLM output tokens/latency (local-first). Actions: record|report|json|reset|status.
ctx_pack PR Context Pack. action=pr yields changed files, related tests, impact summary, and relevant context artifacts.
ctx_proof Export a machine-readable ContextProofV1 (Verifier + SLO + Pipeline + Provenance). Writes to .lean-ctx/proofs/ by default.

ctx_workflow

ctx_workflow implements state-machine-driven workflows for complex multi-step tasks. Define named workflows with ordered steps, transition between states, and enforce evidence collection at each stage.

Parameters

ParameterTypeRequiredDescription
actionstringNoWorkflow operation to perform
namestringNoWorkflow name (for create/start)
keystringNoWorkflow key / identifier
specstringNoWorkflow specification (JSON)
tostringNoTarget state for transition
valuestringNoEvidence value for the current step

Example: Bug Fix Workflow

ctx_workflow action="start" name="bugfix" spec='{"steps":["reproduce","diagnose","fix","test","verify"]}'
→ Workflow bugfix started at step: reproduce

ctx_workflow action="transition" key="bugfix" to="diagnose" value="Reproduced in test_auth.rs:42"
→ bugfix: reproduce → diagnose (evidence saved)

ctx_handoff

ctx_handoff enables context transfer between sessions or agents. Save your current context (files, decisions, progress) and restore it in a new session without re-reading everything.

Parameters

ParameterTypeRequiredDescription
actionstringNoHandoff operation
pathstringNoPath for save/load
pathsstring[]NoMultiple paths to include
apply_knowledgebooleanNoInclude knowledge base in handoff
apply_sessionbooleanNoInclude session state
apply_workflowbooleanNoInclude workflow state

Example: Save & Restore Context

# Save current context before ending session
ctx_handoff action="save" apply_knowledge=true apply_session=true
→ Context saved: 12 files, 3 knowledge entries, 1 workflow

# In new session: restore everything
ctx_handoff action="load"
→ Restored: 12 cached files, 3 knowledge entries, workflow "bugfix" at step "test"

ctx_execute

Run code in sandboxed subprocesses across 11 languages. See the full ctx_execute documentation for language support and examples.

ctx_feedback

ctx_feedback records quality signals about tool usage - latency, token counts, model info, and free-form notes. This data feeds into LeanCTX's adaptive optimization over time.

Parameters

ParameterTypeRequiredDescription
actionstringNoFeedback operation
intentstringNoWhat the agent was trying to do
modelstringNoLLM model name
latency_msnumberNoTime taken in milliseconds
llm_input_tokensnumberNoInput token count
llm_output_tokensnumberNoOutput token count
notestringNoFree-form quality note

ctx_pack v3.4.5

ctx_pack generates a PR Context Pack: changed files, related tests, impact summary, and relevant context artifacts - ideal for code reviews and handoffs.

ParamTypeReqDescription
actionstringNopr (default) - generate PR pack
outputstringNoOutput directory (default: stdout)

ctx_proof v3.4.5

ctx_proof exports a machine-readable ContextProofV1 artifact containing verifier results, SLO evaluations, pipeline metrics, and provenance data. Proofs are written to .lean-ctx/proofs/.

ParamTypeReqDescription
formatstringNojson (default) or html