Skip to content

Multi-Agent Development Architecture

This page is for maintainers of scheduling, authorization, backends, and acceptance. Multi-Agent and Global Agent define user startup and tool contracts; Architecture describes general layering.

Roles, Processes, and Source Ownership

1
2
3
4
Global host: persistent conversation, catalog, task reuse and result notifications
  └─ Shared Master: preparation, launch queue, lifecycle, history and result acceptance
  └─ Super child process: one workflow, StageManager, planning and delegation
       └─ Sub execution session: authorized scope, role tools, backend and submission

This is a responsibility tree, not one Python process per role. Super is a separate task process; Super schedules Sub sessions, whose command-line backends launch their own CLI processes. LangChain and CLI backends share authorization/acceptance boundaries; natural-language promises do not provide isolation.

Source Ownership
ucagent/core/multi_agent/mode.py Public single/multi modes and internal Super identity validation
ucagent/core/multi_agent/global_agent/ Workflow catalog, launch contracts, role tools, artifact receipt validation
ucagent/runtime/agent_sessions.py Persistent conversation references, compatible-task discovery, task operations and notifications
ucagent/runtime/task_contracts.py / agent_view.py Transport-independent task client contract and shared Global/standalone TUI state projection
ucagent/runtime/task_queue.py Ordering, per-session parallelism and resource capacity over the same task records
ucagent/runtime/task_store.py / workflow_evidence.py Recoverable management commits, history and budgets; exit-evidence verification and immutable artifact publication
ucagent/runtime/agent_events.py / events.py Serialized Global input/result delivery and shared EventBuffer archives
ucagent/interfaces/server/api_master/ Shared Web/Multi HTTP routes, executors and preparation/relaunch coordination; task_client.py implements the HTTP adapter
ucagent/interfaces/server/api_cmd/ Shared runtime state, events, operations, pause, guidance and review
ucagent/core/multi_agent/super_agent/service.py Plans, Sub scheduling, cancellation, and post-execution acceptance
ucagent/core/multi_agent/super_agent/supervisor.py StageDriver, scope leases, exclusive mutation ownership, and step tokens
ucagent/core/multi_agent/super_agent/worker.py Sub tool binding, input/output boundaries, and submission prerequisites
ucagent/core/agent/session.py / ucagent/core/backends/cmdline.py Backend sessions and client endpoint/configuration/process lifecycle

The application connects these components and injects endpoint and launcher capabilities; core does not import runtime or interfaces to construct network services. Global owns public multi workflow selection; the internal engine in core/workflow/ is not part of this public startup chain. See Workflow Handoff.

Master and Runtime Boundaries

AgentSessions receives a TaskClient; it does not construct HTTP paths, decode response envelopes or catch requests exceptions. The HTTP adapter maps connection failures to TaskUnavailable and missing tasks to TaskNotFound. Global and standalone TUI share state projection. Runtime snapshots cannot overwrite task identity, process state or accepted evidence, or merge another client's state into the current execution.

Master retains the single task collection, launch lock and executors. TaskQueue orders that collection and evaluates capacity without a second queue or task database. TaskStore and WorkflowEvidence receive explicit data and a history root, never a Master object. The Master monitor probes processes/services; list and detail queries read its snapshot. Each Global notification pass and list projection uses one batch read. Detail views may query the selected task's CMD without probing every task. Lists may lag by one monitor cycle.

Source manifests and generic copying share exclusions; ordinary hidden files participate in the digest. Master validates and saves the manifest on admission, compares it before and after preparation, and verifies bytes while copying. The selected configuration file is covered by the resolved business-configuration digest, so changing model providers can still reuse business progress. Changed inputs fail explicitly and require resubmission; they cannot silently replace content under the old business identity.

Persistence has these boundaries:

  • TaskStore first persists pending_commit.json containing agents.json, tasks.json and workspaces.json, then publishes each document. Reopen finishes replay before loading state. The writer lease and per-file atomic replacement remain. Budgets, receipts and archives have independent persistence; this is not a transaction across every file. External readers must use the API instead of treating three direct file reads as a concurrent transaction snapshot.
  • Hot inbox state retains all pending messages and the latest 20 terminal turns. Older messages are archived first under inbox_history/messages/; inbox_history/events/ indexes notification deduplication. A separate durable sequence prevents ID reuse. A backlog of 1000 pending messages explicitly rejects further admission without dropping accepted work. Legacy lists migrate on first reopen.
  • Every 256 archived events, EventBuffer checkpoints retained views and a byte cursor. Reopen reads the remaining tail; legacy logs without a checkpoint require one initial full scan. An unfinished final record is preserved as events.jsonl.damaged-* before recovery, which publishes a warning. Malformed newline-terminated records still fail. The checkpointed prefix is treated as durable content. Full archives remain available in the existing paginated event format; disk history is not automatically deleted.

Event Attribution and Display Contract

Producers distinguish model exchanges, system output, and HTTP through event source, kind, and message role. TUI uses event_display.py to select Messages / System logs / HTTP consistently, without interpreting strings such as [INFO] in message bodies. Ordinary Console output retains its existing text format; model terminal echoes and raw copies are not projected into Console again. Sub events carry worker_id/worker_attempt. Private MCP services have explicit ownership; shared CMD/Master services must not accidentally inherit the current tool's Sub identity.

Tool-event text is the display projection, while content holds the original body. The MCP adapter prefers a tool's format_mcp_message; otherwise it applies the existing display_result to results and renders remaining dictionaries/lists through format_message_value. Strings remain verbatim and actual MCP return values are unchanged. Display fields cannot replace protocol data or acceptance evidence. See Global Agent for archive paths and truncation boundaries.

Do Not Collapse Every State into done

Layer What passing or ending means What it does not imply
BatchTask Current batch artifacts pass and the next batch may begin Entire stage completion
Sub submission Result submitted and execution preparing to stop Process/tool teardown or final artifact acceptance
Sub validation Authorized inputs/outputs pass their checks Final gates for the whole delegated scope pass
StageDriver finalization All writers stopped and applicable scope acceptance passed Super has exited or Global received the result
Super receipt Runtime recorded workflow completion and artifact digests Master verified task/client identity, exit outcome, and files
Global request completion Child tasks are terminal and result notifications processed Process exit, which also depends on the exit option

UI snapshots, scheduling state, and business receipts must retain their distinct meanings; do not rename or copy fields merely to make them appear consistent. See Global Agent for evidence locations and exit conditions.

Authorization and Stage Advancement

StageDriver acquires a lease for a delegation, recording its root, descendant sequence, and expected stage position. It calls the existing StageManager under exclusive ownership; late requests cannot bypass an invalid lease or changed current stage.

  • Check runs existing validation and BatchTask transitions for the authorized step. The next normal batch stays with the same Sub rather than returning to Super for replanning.
  • CompleteSubStage advances only the current authorized descendant using the latest step_token. Continue with the returned tips/token; an old token returns STALE_STEP_TOKEN and must not be blindly replayed.
  • step_token authorizes descendant progression; it is not the control_revision used by HTTP/human review. They guard different stale-write scopes and are not interchangeable.
  • A single-stage ready submission requires valid current checks, all batches passed, applicable Skill evidence, and a journal. Tools that may change business results invalidate the previous check credential and require another Check.
  • Subtree submission requires all authorized descendants to finish. File tasks receive no stage tools and validate explicit input/output and artifact contracts. needs_attention can report unfinished work but cannot bypass success gates.

The role tool matrix defines availability and callers. Do not re-expose root-stage Complete to Subs or supervisors just to make tool names uniform.

Submission, Teardown, and Final Acceptance

After a Sub returns its result, its execution thread still owns tool/backend cleanup, protected-input checks, and declared-artifact validation/publication. Construction, running, submitted-but-not-exited, and cancelling-but-not-exited tasks retain capacity. Receiving submission text must not free slots or start conflicting writers.

Once all writers stop, _accept_scope recomputes artifact digests and calls StageDriver.finish. Ordinary roots run their existing final gates; a pure group closes the scope after its descendants finish without adding a fictional parent Checker. These branches represent different stage structures, not different standards of business correctness.

After Super actually exits, Master verifies task/workspace/client identity, workflow, stages and artifacts, and saves an immutable accepted snapshot. Global references that result. A zero exit code, a model's completion claim, or a receipt file alone is insufficient. Runtime records are not a manual recovery interface.

Cancellation, Recovery, and Security

Cancel requests, backend termination, tool draining, and scope release are separate events. Recovery planning must use the latest batch state; changing plan/task names must not reset cumulative budgets or completed batches. Live paused tasks recover through CMD. Exited tasks continue in place through the shared /api/relaunch, retaining task/workspace identity with a new client.

Stage/subtree tasks inherit workflow write policy; split file tasks use private copies of declared inputs/outputs and publish validated artifacts. Directory isolation, read-only restrictions, and MCP authorization are not an OS sandbox; native CLI capabilities require separate controls. Endpoint credentials and generated configuration must stay out of public diagnostics.

Validation After Changes

  • Expired leases, wrong stages, stale tokens, duplicate/late submissions cannot advance stages.
  • Multi-batch work retains one Sub; recovery uses current batch state, and premature submission does not end a repairable session.
  • Cover acceptance and rejection for subtree/single-stage, pure-group/gated-root, and file-task scopes separately.
  • Reject post-submission artifact changes, protected-input changes, missing journal/Skill evidence, and forged receipts.
  • Cancellation retains capacity through teardown and finalizes only after all writers stop; missing CLI session IDs cannot resume unrelated conversations.
  • Test shared Master preparation failures, in-place relaunch, receipt identity/digest errors, result notifications and automatic exit. Cover hidden inputs and changes during queueing/copying, task deletion, batch queries, archive deduplication, truncated-event recovery and interrupted multi-file commits, as well as writer leases, persistent allocation, late heartbeats, submission idempotency and durable budgets.

Deterministic offline backends validate scheduling and protocols, not real models, MCP client capability restrictions, or EDA integration. Keep public identifiers and startup examples synchronized through contract tests as well.

Documentation regression has two layers: tests/test_docs_contracts.py runs with ordinary unit tests to check launch examples, expanded Make commands, example imports, and bilingual identifiers; tests/test_docs_i18n.py requires documentation dependencies and checks the actual site's bilingual pages, navigation, and anchors. Neither replaces the other; run mkdocs build -f mkdocs.yml --strict after page or navigation changes. tests/test_dependency_boundaries.py checks layer constraints through root-package imports.