Skip to content

Shared File Protocol

Related source file: src/agentmux/workflow/orchestrator.py

Agents communicate via files in .agentmux/.sessions/<feature-name>/. Files are grouped by phase subdirectories and created on-demand as needed, while a small set of root runtime artifacts is maintained directly by the orchestrator.

Root files

Phase artifacts

For the full artifact listing per phase (files, writers, readers, formats, and transitions), see docs/phases/:

See also docs/artifacts/ for full schema documentation of key session artifacts.

Key functions

  • PipelineOrchestrator.run() / build_event_bus() in src/agentmux/workflow/orchestrator.py — run the phase loop on top of a shared session event bus
  • EventBus in src/agentmux/runtime/event_bus.py — generic dispatcher plus start/stop lifecycle for dedicated event sources
  • FileEventSource / FeatureEventHandler in src/agentmux/runtime/file_events.py — normalize watchdog activity under the feature directory and publish file.* events
  • CreatedFilesLogListener / seed_existing_files() in src/agentmux/runtime/file_events.py — enforce created-file logging semantics (created_files.log, first-seen only, bootstrap coverage)
  • ToolCallEventSource in src/agentmux/runtime/tool_events.py — tail tool_events.jsonl and publish tool.<name> events into the EventBus; seeded at startup, then watched via watchdog
  • InterruptionEventSource in src/agentmux/runtime/interruption_sources.py — publish interruption events when registered tmux panes disappear
  • WorkflowEventRouter.enter_current_phase() in src/agentmux/workflow/event_router.py — explicitly bootstraps the active phase before steady-state event processing starts
  • build_*_prompt() in src/agentmux/workflow/prompts.py — loads and renders the markdown template for each phase; called lazily by handlers
  • Handler functions in src/agentmux/workflow/handlers/ — each builds and writes its prompt file just before sending to agent

MCP Tool Event Protocol

When agents call MCP tools (submit_architecture, submit_plan, submit_review, submit_done, submit_research_done, submit_pm_done), the submission tools read the agent-written file, validate it, and append a minimal signal entry to tool_events.jsonl. Validation errors are returned immediately so agents can correct their files. The tools write no workflow artifacts themselves — agents always own writing the output files.

Each entry has this shape:

json
{"tool": "<tool_name>", "timestamp": "<ISO-8601>", "payload": {...}}

ToolCallEventSource tails tool_events.jsonl and emits SessionEvent(kind="tool.<name>") events into the EventBus. The orchestrator persists an applied cursor in tool_event_state.json after each tool event is handled, so resume replays only unapplied signals. The WorkflowEventRouter routes tool events via ToolSpec to the appropriate phase handler, which materializes .md companions from the agent-written .yaml (if missing) and drives state transitions.

Agents write workflow artifact YAML files directly. The MCP submission tools validate the agent-written file and signal the orchestrator to advance — they do not write files themselves.

Workflow Events

state.json contains a last_event field that records the most recent workflow event driving the current phase. The authoritative catalog of valid values and display metadata is in src/agentmux/workflow/event_catalog.py. Phase-to-event emission wiring lives in src/agentmux/workflow/phase_registry.py via PhaseDescriptor.emitted_events. Unknown values are rejected at write time by validate_last_event() in phase_helpers.py.

ConstantString ValueDisplay LabelEmitted ByConsumed ByTransitions To
EVENT_FEATURE_CREATEDfeature_createdstarting upstate_store.create_feature_files()
EVENT_RESUMEDresumedresumedsessions.prepare_resumed_session()reviewing phase enter
EVENT_PM_COMPLETEDpm_completedpm doneProductManagementHandlerarchitecting
EVENT_ARCHITECTURE_WRITTENarchitecture_writtenarchitecture readyArchitectingHandlerplanning
EVENT_PLAN_WRITTENplan_writtenplan readyPlanningHandlerimplementing enterdesigning, implementing
EVENT_DESIGN_WRITTENdesign_writtendesign readyDesigningHandlerimplementing enterimplementing
EVENT_IMPLEMENTATION_COMPLETEDimplementation_completedcode doneImplementingHandler, FixingHandlerreviewing
EVENT_REVIEW_FAILEDreview_failedfix neededReviewingHandlerfixing enterfixing, completing
EVENT_REVIEW_PASSEDreview_passedreview passedReviewingHandler
EVENT_CHANGES_REQUESTEDchanges_requestedchanges askedCompletingHandlerplanning enter, implementing enterplanning
EVENT_RUN_CANCELEDrun_canceledcanceledorchestrator interruptionfailed
EVENT_RUN_FAILEDrun_failedrun failedorchestrator interruptionfailed

The table above summarizes runtime behavior from three sources: event metadata in event_catalog.py, phase emission wiring in phase_registry.py, and the phase-local consumption/transition logic in the individual handler modules.

Released under the MIT License.