frontieragentAgent
§ · Nested detail page

Agent Team profile、runtime 与共享工作区 深度解析

这一页拆 Agent Team 如何从 profile 进入 sub-agent runtime,以及它如何把共享 workspace、/inputs、/outputs 和 scratch 目录写进模型可见上下文。

§ 00 · IMPORT CHAIN

导入链与契约

Agent Team 的入口是 profile,而不是硬编码 prompt。sources/frontieragent/workflows/agent_team/profile.py:48 先解析 reporter 是否启用,sources/frontieragent/workflows/agent_team/profile.py:68 解析 reporter backend,sources/frontieragent/workflows/agent_team/profile.py:132 再加载 YAML 或 inline profile。这个设计让 benchmark、TUI 和 Docker API 可以共用 workflow,只替换 profile。

src/workflows/agent_team/profile.py · L48-85Python
48def resolve_reporter_enabled(
49    profile: dict[str, Any] | None,
50    *,
51    pipeline_id: str,
52    profile_name: str | None,
53) -> bool:
54    """Return the effective agent-team reporter switch.
55
56    Both agent-team specs use the profile flag.  The report-named pipeline and
57    profile retain their historical default-on behaviour only when the merged
58    profile does not explicitly contain ``agent.reporter``.
59    """
60    agent_cfg = (profile or {}).get("agent") or {}
61    reporter_default = (
62        pipeline_id in ("agent_team_report", "agent-team-report")
63        or profile_name == "agent_team_report"
64    )
65    return bool(agent_cfg.get("reporter", reporter_default))
66
67
68def resolve_reporter_backend(profile: dict[str, Any] | None) -> str:
69    """Resolve the backend name while keeping the future-backend seam stable.
70
71    Fast is the only shipped backend and remains the safe default. Compatibility
72    aliases resolve here so the dispatcher can return an actionable error.
73    """
74    agent_cfg = (profile or {}).get("agent") or {}
75    raw = str(agent_cfg.get("reporter_backend") or REPORTER_BACKEND_FAST)
76    normalized = raw.strip().lower().replace("-", "_")
77    backend = _REPORTER_BACKEND_ALIASES.get(normalized)
78    if backend is not None:
79        return backend
80    logger.warning(
81        "Unknown agent.reporter_backend=%r; using %s",
82        raw,
83        REPORTER_BACKEND_FAST,
84    )
85    return REPORTER_BACKEND_FAST
§ 01 · CORE IMPL

核心实现,逐段拆

▸Runtime 真实描述文件系统边界

sub-agent runtime 会根据 sandbox_mode 和 inputs_available 渲染不同的 filesystem note。sources/frontieragent/workflows/agent_team/subagent_runtime.py:72 到 sources/frontieragent/workflows/agent_team/subagent_runtime.py:168 不只是文案,它规定共享 workspace、私有 workspace、/inputs、/outputs、scratch 和 publish manifest 的含义,直接影响 sub-agent 是否会互相覆盖产物。

src/workflows/agent_team/subagent_runtime.py · L72-112Python
72def render_sandbox_fs_note(
73    *,
74    sandbox_mode: str,
75    inputs_available: bool,
76    audience: str,
77) -> str:
78    """Render truthful filesystem context for the active sandbox topology."""
79    shared = sandbox_mode in ("container", "native")
80    location = "this native workspace" if sandbox_mode == "native" else "this container"
81    workspace_path = (
82        os.environ.get("FRONTIER_AGENT_WORKSPACE_DIR", "the workspace")
83        if sandbox_mode == "native" else "/workspace"
84    )
85    inputs_path = (
86        os.environ.get("FRONTIER_AGENT_INPUTS_DIR", "the inputs directory")
87        if sandbox_mode == "native" else "/inputs"
88    )
89    outputs_path = (
90        os.environ.get("FRONTIER_AGENT_OUTPUTS_DIR", "the outputs directory")
91        if sandbox_mode == "native" else "/outputs"
92    )
93    project_path = os.environ.get("FRONTIER_AGENT_PROJECT_DIR", "").strip()
94    if audience == "sub":
95        workspace = (
96            f"{workspace_path} is shared by the coordinator and all sub-agents in "
97            f"{location}; use distinctive subdirectories and never assume "
98            "unlabelled files are yours."
99            if shared
100            else f"{workspace_path} is private to this sub-agent."
101        )
102    else:
103        workspace = (
104            f"{workspace_path} is shared by the coordinator and all sub-agents in "
105            f"{location}."
106            if shared
107            else f"{workspace_path} contains the coordinator worktree and the "
108            "sub-agents' private worktree directories."
109        )
110    inputs = (
111        f"Task input files are available under {inputs_path}."
112        if inputs_available

▸长上下文疲劳时强制工具或报告

runtime 还定义了 sub-agent 不能只输出普通文本的 nudge。sources/frontieragent/workflows/agent_team/subagent_runtime.py:175 要求每回合以工具调用结束,sources/frontieragent/workflows/agent_team/subagent_runtime.py:181 在 finalization reserve 里要求停止探索并提交 report。这让长任务在预算末尾有结构化收尾。

src/workflows/agent_team/subagent_runtime.py · L175-194Python
175_SUBAGENT_NO_TOOL_NUDGE = (
176    "Every turn must end with a tool call. When you have gathered enough "
177    "evidence, call `submit_report` with your Scope/Finding/Evidence report. "
178    "Otherwise call a data-gathering tool (web_search, web_fetch, read_file, "
179    "bash). Do not reply in plain text."
180)
181_SUBAGENT_FINALIZATION_MESSAGE = (
182    "Your assignment is entering its finalization reserve. Stop new "
183    "exploration. Finish and validate the best current artifact in /workspace; "
184    "if this assignment has publish permission, publish exactly its declared "
185    "/outputs manifest. Then call `submit_report` with concrete findings and "
186    "file paths. Submit a useful partial report even if some work remains."
187)
188_RECOVERY_NUDGE_PREFIXES = (
189    # This workflow's own sub-agent control messages, on top of the framework set.
190    _SUBAGENT_NO_TOOL_NUDGE,
191    _SUBAGENT_FINALIZATION_MESSAGE,
192    "[stop signal] The coordinator has asked you to STOP immediately.",
193    *COMMON_RECOVERY_NUDGE_PREFIXES,
194)
§ 02 · KEY FLOW

关键流程

load_swarm_profile │ env vars + overrides ▼ workflow runtime metadata │ sandbox_mode / paths / reporter backend ▼ main coordinator prompt ├─ create_subagent(role label) ├─ assign_task(output manifest optional) └─ collect_reports(status blocks)

▸配置先合并,再进入提示词

这个顺序让 profile 成为可测试的工程对象:sources/frontieragent/workflows/agent_team/profile.py:173 先解析环境变量占位符,sources/frontieragent/workflows/agent_team/profile.py:175 再应用 overrides,最后由 sources/frontieragent/workflows/agent_team/subagent_runtime.py:151 把可发布路径写进模型可见说明。

这个流程说明 Agent Team 的“团队感”来自运行时约束而不是 prompt 幻觉。sources/frontieragent/workflows/agent_team/profile.py:173 先解析 env placeholders,sources/frontieragent/workflows/agent_team/profile.py:175 再应用 overrides,sources/frontieragent/workflows/agent_team/subagent_runtime.py:145 则给主 Agent 加上 output manifest namespace 提醒。

§ 03 · EDGE CASES

边界 / 失败模式

  • Inline profile 可以绕过文件查找,但仍会走 env-var resolution:sources/frontieragent/workflows/agent_team/profile.py:164。
  • 未知 reporter backend 不会直接炸掉,而是 warning 后回到 fast backend:sources/frontieragent/workflows/agent_team/profile.py:80。
  • container/native 共享 workspace,bwrap 私有 workspace;差异在 sources/frontieragent/workflows/agent_team/subagent_runtime.py:79 和 sources/frontieragent/workflows/agent_team/subagent_runtime.py:119。
  • outputs physical path 和 virtual manifest path 被明确区分:sources/frontieragent/workflows/agent_team/subagent_runtime.py:145 到 sources/frontieragent/workflows/agent_team/subagent_runtime.py:151。
Sub-page · 2026-08-26 Source · ApodexAI/FrontierAgent ↑ frontieragent 主页面