Architecture and Operation¶
UCAgent defines tasks through workflows, executes them through an Agent and its tools, and accepts artifacts through stages and Checkers. The package groups existing capabilities by responsibility: a complete Agent in core/, startup in launcher/, instance ownership in runtime/, and human/network access in interfaces/.
Directory Responsibilities¶
| Directory | Responsibility |
|---|---|
core/agent/ | Task configuration, Agent-owned construction, execution, messages and statistics |
core/backends/ | LangChain, command-line and blank backends; client configuration templates in assets/ |
core/interaction/ | Enhanced execution, reflection and adaptive tool orchestration |
core/stage/ | Stage progression, Check/Complete, history, human/model review |
core/checkers/ | Checker lifecycle, diagnostics and BatchTask |
core/multi_agent/ | Global/Super/Sub contracts, delegation, authorization and acceptance coordination |
core/workflow/ | Embedded workflow handoff contracts and chain state; not the public multi Global orchestration entry |
core/tools/ | Complete generic file, shell, planning, memory, context and Skill tools |
core/workspace/ | Task documents/templates/skills, instruction generation and permission restoration |
core/plugins.py | Plugin declarations, discovery, validation and capability registries |
core/locales/ | Framework language configuration; Chinese defaults are zh.yaml |
launcher/ | Entry orchestration, launch requests/plans, workspace sources, logging and runtime wiring |
launcher/presets/ | Application-mode presets, including zh/master.yaml |
runtime/ | Host lifetime, operation scheduling/cancellation, service ownership, sessions and output buffers |
runtime/control/ | Controller, command schemas, dispatch and plugin command registration |
interfaces/cli/ | CLI syntax, management actions and conversion to launch data |
interfaces/terminal/ | Console and result formatting; TUI lives in tui/ |
interfaces/server/ | HTTP, MCP, Master, Web Terminal, pages, static assets and viewer conversion |
applications/ | Independently owned workflow projects and their documents/templates/skills and domain implementations |
util/ | Shared configuration, file policy, logging and other foundation functions |
core/ contains the full Agent implementation, including concrete backends and tools. It is not limited to abstract interfaces. Plugin resources stay with their workflow; core preparation selects and materializes them as one task contract. Root setting.yaml remains the cross-layer defaults file.
Directory Dependency Direction¶
The arrows show source dependency direction. The launcher selects the service and presentation implementations and supplies them to the runtime.
flowchart TB
LAUNCHER["launcher/<br/>Startup and wiring"] --> APPS["interfaces/<br/>CLI, terminal and network access"]
LAUNCHER --> RUNTIME["runtime/<br/>Control, scheduling and lifetime"]
LAUNCHER --> CORE["core/<br/>Complete Agent capabilities"]
LAUNCHER --> PLUGINS["applications/<br/>Workflow projects"]
APPS --> RUNTIME
APPS --> CORE
RUNTIME --> CORE
PLUGINS --> CORE
CORE --> UTIL["util/<br/>Shared foundations"]
LAUNCHER --> UTIL
RUNTIME --> UTIL
APPS --> UTIL tests/test_dependency_boundaries.py checks the package boundaries in the diagram across absolute, relative and function-local imports. The checks apply to package boundaries and allow dynamic plugin loading.
The launcher supplies service constructors. Runtime sessions receive result-formatting callbacks from the launcher and terminal interfaces. Runtime control registers plugin commands.
Startup, Execution and Shutdown¶
ucagent,python -m ucagent, and sourceucagent.pyreachlauncher/entry.py, which calls CLI parsing and handles management requests before constructing an Agent.- CLI conversion supplies launch data. The launcher creates a
LaunchRequest, prepares the workspace and logging, and invokes core task configuration. Framework prompts and named launch presets come fromcore/locales/<language>.yamlandlauncher/presets/<language>/, respectively. Configuration precedence core/agent/construction.pyprepares selected workflow resources and constructs stages, tools, backends and execution state. Python callers use the same path throughfrom ucagent import VerifyAgent, without importing application startup.- The launcher creates RuntimeHost and sessions, supplies concrete service constructors and presentation callbacks, and hands over cleanup. MCP and other requested services become ready before user/model startup commands execute.
- Startup commands retain their ordering. TUI readiness releases the display gate; runtime owns their execution. Tasks without an interface or service default to execution; service and interactive launches wait for explicit model work.
- Runtime schedules Agent work. Backends invoke tools; stage tools enter the same StageManager and Checkers. HTTP controls the runtime, while MCP exposes the same task tools. MCP calls do not automatically create HTTP operation IDs.
- TUI detaches without closing the task. Instance shutdown drains work and services, persists state, and restores acquired resources. Workspace-contained shared-library links retain their original target permissions.
LangChain prepares models on first model work. Command-line backends prepare against a ready MCP endpoint. Queries and deterministic tools do not prepare the main model; explicitly enabled embedding/review capabilities retain their own requirements. See Runtime Control.
Stage Execution Loop¶
This diagram describes public tool calls in single mode. Multi reuses stage acceptance, but Sub checks/submits and the framework finalizes; see the role tool matrix and Multi-Agent Development Architecture for permissions and ownership.
flowchart TD
A[Enter Current Stage] --> B[Read Tasks and Reference Files]
B --> C[Call Tools and Generate Outputs]
C --> D{Check or Complete}
D --> E[Check References, Outputs, and Checker]
E --> F{Check Passed?}
F -- No --> G[Fix Based on Diagnosis]
G --> C
F -- Check --> H[Return Check Result or Next Batch]
H --> C
F -- Complete --> I{Final Acceptance and Stage Gate Passed?}
I -- No --> G
I -- Yes --> J{More Stages?}
J -- Yes --> A
J -- No --> K[Workflow Complete] Check does not advance the stage, but batch Checkers can switch to the next batch after passing. Complete performs its own final check; ordinary stages do not require calling Check first. The "No Applicable Work" branch of skills additionally requires the current Check to pass; see Skills.
How Stages Accept¶
reference_filesdeclares reference files that need to be read. Read records are generated by theReadTextFiletool; file reads by external clients are not logged.output_filesdeclares required output paths or patterns. File existence is just the first condition; content rules are verified by the Checker.checkerexecutes in configuration order, returning a diagnosis upon the first failure.Completealso requires applicable skills and human review for the current stage.
Checkers do not automatically pass just because the Agent claims "completed." Custom Checkers should verify observable facts and return specific locations, expected conditions, and next steps on failure. Lifecycle and batch rules are detailed in Custom Checkers.
Operation, Stage Control, and Persistence Boundaries¶
OperationExecutorrecords IDs, states, results, errors, cancellation flags, sessions, and parent/child relationships for long operations. One top-level model operation is admitted per instance; queries need not wait for it to finish.- Cancellation is cooperative. The model slot is released only after work actually ends.
RuntimeHostinitiates shutdown, drains operations, persists state, synchronizes the workspace, closes services, and restores resources. Detaching a view does not own these steps. StageCoordinatorcoordinates stage writes and maintainscontrol_revision. Human review and flag updates use the observed revision to reject conflicts and stale writes. Approve-and-continue saves approval before submitting continuation.- Check/Complete business rules remain in
StageManager/VerifyStage. Coordination does not bypass Checkers, reading records, stage journals, skills, or human review gates. - Stage state, history, and tool evidence retain their existing persistence mechanisms. Operation records and output buffers are primarily in memory. Long-operation recovery across process restarts, unified decision-event replay, and remote TUI reattachment are not implemented.
Plugins explicitly contribute tools, Checkers, resources, stage hooks, and commands; see Runtime Commands. Backends still load classes from configuration and service assembly retains dedicated entry points; the current implementation does not place every capability behind one plugin contribution contract.
Public API and Role Assembly¶
PUBLIC_API_NAMES in ucagent/api.py lists the root package's lazy public extension interfaces using all keys in _EXPORTS. Dependency checks resolve these names to their defining modules. Public interfaces
Ordinary assembly selects services and tools by role during Agent construction: single retains business tools; Global exposes discovery, launch, and result tools; Super exposes delegation tools and assigns business tools to authorized Subs. The application injects process launchers, MCP endpoints, and presentation capabilities, without reverse imports from core. Global owns public multi workflow orchestration; see Workflow Handoff for the optional internal handoff startup branch.
Boundaries of Configuration and Resources¶
Variables like {DUT} and {OUT} in workflow configurations are rendered after configuration loading. Guide_Doc is a file that must be read during runtime; initial templates are copied to the workspace via the template rendering process. Files listed in reference_files do not automatically imply their contents undergo variable substitution. See Template Files and Generated Outputs for writing guidelines for both resource types.
Skills can accelerate tasks, but when skills are disabled or the skill directory is missing, the stage must still have a complete task description, standard tool paths, and identical acceptance criteria.
The Master page and task management mechanism are described in Web Master User Guide. When beginning to write extensions, continue reading Custom Development Introduction and Workflow Configuration.