JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.
JiuwenSwarm Technical Direction and Applicable Code Review Standards
导航表、语言与验证入口按本分支 e8c1126df 核对。它们描述代码应遵守的机制和方向,不表示既有代码已经全部符合。下方未改写的技术标准仍保留迁入时的表述,使用时分别对照检视基线、适用的项目说明和已确认的设计。
模块规则与契约导航
先从变更路径向上读取适用 AGENTS,再读取相关子模块规则。模块引用的特性规则可能覆盖目录外调用方,不能只按文件所在目录判断。
下表只列本分支实际存在的入口。本分支没有 sdks/、channels/process_cli/、jiuwenswarm/runtime/session/、channels/web/AGENTS.md,也没有前端 settings、ui、trajectory 的 AGENTS.md。这些路径不是检视入口。
| 模块/场景 | 真实契约入口 | 检视重点 |
|---|---|---|
| Server 与会话 | 根规则;Server 规则;请求流水线;Agent 管理;会话目录;AgentManager | 产品会话和 agent 生命周期在 jiuwenswarm/server/runtime/。jiuwenswarm/runtime/__init__.py 只提供 push 的 install/restore/send,不是 Session Runtime。 |
| Gateway | Gateway 接口说明 | 改接口时修订该目录里已有的接口文档。不在旁边新建 specs/ 或 features/。 |
| E2A 与跨端消息 | 中文协议;英文协议;模块 spec;E2A 模型与 codec;共享消息 schema | 协议文档、生产方、Gateway/AgentServer 转换、各渠道和旧消费者一起核对。 |
| Web 与前端 | 前端规则;测试入口;TUI 包 | 只按实际存在的前端规则和本次改到的文件检视。本分支没有独立的 Web、settings、共享 UI、轨迹 AGENTS。 |
| 应用 Harness/Team 与 core 依赖 | Swarm 装配;依赖声明;依赖锁;运行时管理 spec | 按基线/候选各自框架版本读取 core 模块规则/spec;保留本地 editable 与已提交依赖证据的区别,不直接套用 core 的全仓规则。 |
| 沙箱、资源与交付 | 沙箱说明;运行时路径函数;沙箱生命周期;部署目录 | 检查路径/进程/权限、配置模板与包资源;Windows/macOS/Linux 和源码/安装包路径按影响验证。 |
规约入口是受影响模块的 docs/specs/ 与 docs/designs/。已有设计叙事描述当时方案,不自动替代当前 spec。
遇到 AGENTS、协议、schema 与代码冲突时,区分文档漂移、实现回归和未确认契约变化,报告证据并交接开发。
本地 AGENTS.local.md 的禁止格式化/静态检查约束仍适用;模块中的构建、类型检查或 diff 检查命令不构成执行这些检查的授权。
Languages, frameworks, and deliverables
| Area | Current mechanism | Review standard |
|---|---|---|
| Python application | Root pyproject.toml requires Python >=3.11,<3.14, uses uv.lock, and pins openJiuwen to a Git commit. Console entry points include AgentServer, Gateway, Web, CLI, ACP, and jiuwenbox. |
New dependencies, versions, and entry points need a clear requirement and compatibility evidence. Keep locks, packaging, and affected platform checks aligned. Avoid a parallel execution framework for an existing responsibility. |
| Services and protocols | gateway/ accepts and routes channel requests; jiuwenswarm/server/ hosts AgentServer; jiuwenswarm/common/schema/ and common/e2a/ define shared messages and E2A contracts. Transport uses WebSocket, with FastAPI for some HTTP endpoints. |
For protocol, identity, status, error, or stream-terminal changes, check producers, consumers, older clients, and tests. Keep transport encoding at the boundary and give runtime state an explicit owner. |
| Agent execution | Product session and agent lifecycle live in jiuwenswarm/server/runtime/, including agent_manager.py and session/. jiuwenswarm/runtime/ only exposes push install/restore/send. agents/harness/ contains Work/Code/Team Rails, permissions, tools, and extensions. |
Prefer existing public entry points, adapters, Rails, or tool extension points. Do not bypass permission or sandbox controls or introduce a second Runtime with the same responsibility. Shared abstractions need real consumers. |
| Web and TUI | Web and TUI each have a frontend package.json. This branch has no sdks/ package. |
Shared contract changes must account for the frontends and channels that actually exist. A local representation in one client should not replace a shared model. |
Architecture boundaries and evolution
- Session ownership. Product session state and agent lifecycle are in
jiuwenswarm/server/runtime/session/andserver/runtime/agent_manager.py. Readserver/docs/specs/S_02_request-pipeline-dispatch.mdandS_03_runtime-agent-management.mdbefore treating another package as the runtime.jiuwenswarm/runtime/__init__.pyonly exposes push install/restore/send. - Gateway contracts. Channel ingress and HTTP contracts are described by the existing files under
jiuwenswarm/gateway/docs/. Revise those documents when the interface changes. This branch has nosdks/PROTOCOL.mdand no process-channel schema to use as a substitute. - Durable session data. Metadata, history, and related persistence live beside the session package under
server/runtime/session/. Changes must keep a single source of truth for create, switch, and delete, including failure cleanup. Inspect the code andserver/docs/specs/at the baseline and candidate. Do not describe aruntime/session_provisioner.pyorruntime/service.pythat this branch does not have. - Shared channel semantics. Web, TUI, ACP, IM, and other entry points depend on shared request, event, and session contracts. If identity, mode, readiness, cancellation, interaction reply, push, or error semantics change, check the affected channels and both Gateway and AgentServer. Unaffected channels do not require automatic retesting.
- Permissions and extension points.
agents/harness/common/rails/permissions/, AgentManager, Skill/Tool/MCP/Extension facilities, and the jiuwenbox sandbox are existing execution controls. New paths must preserve authorization, trusted-directory checks, sensitive-data protection, and tool lifecycle. Look for an existing Rail, adapter, or registration point before adding a new one.
openJiuwen Harness and Swarm Rail standards
Resolve the framework version used by the review baseline and candidate from their actual dependency configuration. Local development may use an editable checkout; in that case record its path, revision and relevant local changes explicitly, and distinguish that evidence from the committed dependency contract.
openJiuwen is a pinned framework dependency (pyproject.toml and uv.lock); JiuwenSwarm supplies product behavior around it. For each affected change, verify the API against the pinned revision used by the review baseline, not an arbitrary local openJiuwen checkout. If the candidate changes the pin, compare the review baseline revision with the proposed revision and verify Swarm's integration against the proposed one. The concrete assembly points below are from this repository and must be rechecked if the review baseline changes them.
- Framework boundary. openJiuwen
DeepAgentand itsAgentRail/DeepAgentRailcallback model own the agent execution loop. JiuwenSwarm'sserver/runtime/agent_adapter/interface_deep.pybuilds single-agent Rails and connects them to the product Runtime. Generic framework behavior belongs in the upstream contract or a justified framework contribution; product prompts, permissions, events, modes, and tools belong in Swarm's adapter, Harness, or providers. Review any direct use of framework private state for version fragility and a public extension alternative. A change to the pinned framework revision needs a compatibility audit of imports, lifecycle hooks, registration, and affected modes. - Rail lifecycle and ordering. The framework exposes invoke, task-iteration, model, and tool hooks; registration and unregistration also affect rail tools and state. At the pinned revision, Rails initialize in descending
rail.priorityorder with stable ties; callbacks run in descendingrail.callback_priority(event)order, which can differ by event. Model/tool hooks,after_react_iteration,on_user_message, andbefore_steering_drainregister on the inner ReAct agent; invoke and task-iteration hooks stay on the outer DeepAgent. Inspect the hook actually used, its execution layer and ordering against adjacent Rails, sharedctx.extra/session state, initialization, cleanup, and behavior on exception, retry, cancellation, or force-finish. Multiple Rails may use the same callback event; the defect is duplicated responsibility, side effects, prompt content, tool ownership, or registration, not a shared hook name. - Single-agent assembly and mode state.
interface_deep.pydeclares separate agent/code Rail sets and conditionally attaches Rails.server/runtime/agent_manager.pytreats single-agent Plan as session runtime state on the same cached agent so conversation context survives mode switches. Review the actual assembled chain for every affected Work/Code/Plan profile and channel; confirm model-visible tools, prompt state, permission behavior, and context continuity. A Rail required for a mode must be present when that mode becomes active, including after configuration reload. - Reload and dynamic extensions. Rails can be rebuilt, registered live, or toggled by mode.
interface_deep.pycontains explicit post-configure(rails=...)registration handling because pending Rails can otherwise miss the live execution chain.agents/harness/common/plugins/rail_manager.pymanages user Rail extensions. Check idempotent register/unregister, duplicate tool registration, repeated registration of the same callback or duplicate callback effects, retained dynamic Skill state, cache isolation, and cleanup across reload and reused agents. A Rail object being stored on the adapter is not proof that it is active on the running agent. - Permissions and tool execution. Preserve the composed permission, approval, security,
SysOperation, and sandbox path across tool calls and subagents. In particular, review the permission Rail group and its live registration on reload, trusted workspace roots, interaction/interrupt routing, and any mode-specific exceptions. Do not let a new tool, background path, or Team member invoke an equivalent action outside those controls. - Team assembly.
agents/swarm/assembly.py,config_specs.py, andregistry.pybuild Team members from role/profile configuration,RailSpec/tool/subagent provider names, and a per-teamSwarmBuildContext; they do not copy a prebuilt single agent. Check provider registration, manifest names, role-specific and code-profile composition, member workspace/config isolation, and tool/Rail ownership. Avoid a parallel imperative Team assembly path or double-registration of a capability already supplied by a Rail. - Evidence for a Rail change. Tests should prove the behavior through the applicable assembled agent or member, including hook execution, mode transition or reload when affected, and failure/cancellation/permission behavior where relevant. Isolated Rail unit tests alone do not establish that the Rail is mounted or ordered correctly. Use existing assembly and permission contract tests as a guide; require only cases implicated by the change.
Cross-layer contracts to protect
| Contract | Ownership and review questions |
|---|---|
| Agent construction | openJiuwen DeepAgentConfig/factory and Swarm's JiuWenSwarmDeepAdapter construct a single agent; Team members use openJiuwen TeamAgentSpec and Swarm's declarative provider specs. Does the change preserve these two assembly paths and their shared behavior without copying a live agent or building a competing execution loop? |
| Execution and control | openJiuwen DeepAgent runs the inner ReAct agent and optional outer task loop; Team NativeHarness drives rounds and TeamHarness adapts them for members. Does a change to invoke, stream, steer, follow-up, interrupt, pause, abort, or resume preserve the corresponding state transition and the owner of that transition? |
| Context and persistence | The inner ContextEngine owns model conversation context; openJiuwen sessions/checkpointers persist agent state; Swarm owns product session lifecycle and a process-wide persistent checkpointer. Which state is live, checkpointed, or derived? Will it survive reload, mode change, recovery, and session deletion without duplication or leakage? |
| Capabilities and security | AgentRail/DeepAgentRail hooks, AbilityManager, Runner.resource_mgr, SysOperation, and the permission/security Rails jointly determine available and executable actions. Is a capability exposed once, guarded at execution time, and retained or released according to its actual ownership and lifecycle? |
| Team composition and runtime | Swarm SwarmBuildContext, provider manifest, RailSpec/tool/subagent specs, and openJiuwen AgentConfigurator build members; openJiuwen TeamRuntimeManager owns team pool, dispatch, and interaction gate. Are build data, live handles, leader/member identity, and runtime control kept in their respective layers? |
- Identity and resource scope. In the pinned framework,
DeepAgentConfig.card.idis a stable checkpoint identity, whiletool_owner_idseparates live tool registrations that share that card. Swarm fixes its single-agent card ID and scopes tool ownership separately (interface_deep.py). Review card/session IDs, cached agent keys,Runner.resource_mgrregistrations, andSysOperationownership together. A change must not fix tool collisions by changing persistence identity, overwrite another live agent's resource, or remove a shared resource while another user still holds it. - Task-loop, ReAct, and tool-result integrity. Check whether a hook runs on the outer task iteration or inner model/tool loop. Every model tool call needs a matching result in the conversation protocol; a background completion should enter through its intended later-message path rather than inventing a delayed result for an old call. Review bounded iteration, no-progress and retry behavior, especially for actions with side effects. A graceful stop or resume must not replay a completed tool call or leave the model context with an unmatched tool call.
- Interrupt and cancellation semantics. openJiuwen
NativeHarnessdistinguishes queued follow-up, immediate steering, abort of a round, and pause/resume over retained context. A running tool can already have irreversible effects. Review acknowledgements, state transitions, snapshot/rollback points, and cleanup for model calls versus tools. For Team changes, also inspect Swarm's control translation and any background task; do not infer that ending one DeepAgent round ends a persistent Team stream or releases its pool entry. - Prompt and context authority. openJiuwen's prompt builder and ContextEngine are the live model-facing sources; Swarm layers runtime, response, Skill retrieval, memory, and context-processing Rails on them. Check prompt-section ownership, priority, language, deduplication, token budget, and reset/rebuild behavior. Model switching must update the selected model's context-window and tokenizer metadata as well as the model client (
interface_deep.pybuilds the ContextEngine config). Do not treat a logged prompt string or adapter field as proof of the messages actually sent to the model. - Workspace and access boundaries. openJiuwen distinguishes the agent's artifact
workspace, shellcwd, and access-boundaryproject_root. Team members can run in a project or worktree while retaining a private artifact workspace. Check which root each filesystem, shell, Skill, prompt, permission, subagent, and cleanup path uses. Passing a workspace path in place of a project root can broaden access or put durable artifacts in an ephemeral checkout. - Tool, Skill, MCP, and subagent ownership. Inspect the whole route from declaration to registration, model visibility, invocation, hot reload, and disposal. The process-global resource manager and Rail-owned tools require stable IDs and explicit ownership. Team Skill use has a shared physical library plus team/member visibility declarations (
config_specs.py,providers/skills.py); avoid a second library or double-registering Skill management tools. Verify child agents inherit the intended model, tools, permissions, workspace, iteration limits, and stop behavior without inheriting mutable parent state accidentally. - Serializable specs versus live handles. openJiuwen Team specs and
build_context_seedcross process boundaries;SwarmBuildContextcarries live handles only in the process where providers build. Checkto_seed/from_seed,derive()for member fields, provider registration and manifest names, defaults, and spawn payload readers/writers together. A new non-serializable object or implicit local closure in a spec can work in process and fail for a spawned member or cold recovery. - Team state and message boundaries. openJiuwen's Team runtime pool, interaction gate, member startup, checkpoint namespace, message transport, and stream tagging have separate owners. Review leader versus teammate paths, one active team per name/session policy, lazy-start concurrency, persisted team state, and cross-process message delivery. A member-visible change must work when leader and teammate do not share Python objects. A stream/event change must preserve member identity and terminal semantics at the Swarm channel boundary.
- Upstream integration changes. When a change updates the openJiuwen pin or starts using a new API, compare public exports and actual behavior in the baseline and proposed openJiuwen revisions, then check Swarm adapter/provider assumptions against the proposed version. Check config and spec fields, Rail hook routing and priority, hot-reconfigure behavior, session/checkpoint keys, resource registration, Team member construction, and stream/interrupt contracts. Update the lockfile and affected documentation; require integration evidence for the paths that depend on the changed contract.
Treat a demonstrated permission bypass, broken checkpoint identity, lost or duplicated tool execution, cross-session state leak, missing required live Rail, or Team member build failure as a significant architectural finding. For other risks, identify the affected path and observable consequence; a theoretical layering preference by itself is not a defect.
Code, UI, verification, and documentation standards
Apply the repository prohibition on formatters and static checks. The tooling descriptions below are historical context, not instructions to run those tools. Use relevant behavior tests and existing evidence; do not infer a passing result from a configured command.
- Python.
pytest.iniconfigures pytest, asyncio, coverage, and strict markers, withtestpaths = tests. This branch has no rootMakefile, so there is nomake lintormake test.docs/zh/developer_guide.mdrecommendsuv run pytest, includinguv run pytest tests/unit_tests/anduv run pytest tests/. Judge test sufficiency by affected contracts and failure paths; public boundary changes need relevant integration or system evidence. - Web. Applicable Web project instruction files specify Chrome/Chromium 107 compatibility, Prettier, semantic color tokens,
currentColorfor themeable SVGs,data-testidfor touched elements, Chinese and English UI text, and shared Settings components. Webpackage.jsonbuilds withtsc && vite buildand lints with ESLint. Many frontend tests are separatetest:*scripts; select relevant suites rather than assuming a unifiednpm test. - TUI and specialized areas. TUI
package.jsonprovides TypeScript type checking, oxlint, oxfmt, and test scripts. More specific project instruction files, such as the Web trajectory rules, add data-flow, generated-file, and testing constraints for their own paths only. - Change claims and docs. Compare code behavior with the available requirement, design, change description and test evidence. An existing PR description may supply additional context, but a PR, its template, and a linked issue are not prerequisites for code review. Public interface, configuration, and user-visible behavior changes require relevant docs, examples, and migration notes. A future design document is not evidence of current implementation.
- Packaging and multiple clients.
pyproject.tomlpackage-data and exclusions,MANIFEST.in, and the Web/TUI builds have separate delivery boundaries. This branch has nosdks/package. For resource, dependency, or generated-file changes, check source installs and built distributions, and avoid depending on local caches or build artifacts as if they were source files.