## Summary Raven's host acts as the user's agent manager: it delegates production work, including small edits, to the agent whose ownership or description fits the task -- or, on a turn bound to a Worker Table, to the worker whose brief covers it -- keeps track of the task and its instance, routes follow-ups back to that instance, and gathers the results for the user. Its own tools support briefing, checking and coordination. - Add the resident `multi-agent-coding` skill for choosing coding agents, keeping one instance per task, passing results by file, isolating concurrent edits in worktrees, and handing over work when an agent exhausts its quota. - Keep the new host role authoritative in both the DAG skill's resident description and its full guide. A single task uses `spawn`, or a one-node graph when only the DAG dispatch path is available. - Rename the generic sub-agent to `Raven-General`, with `Raven` and `raven` retained as compatibility aliases. Instance records, handle locks, live activity, cancellation, preferences and RPC lookups use the same canonical identity. Historical spawn and DAG readers normalize names before liveness checks and serialization, so tasks and transcripts join the current instance roster. Concurrent alias calls preserve both turns instead of overwriting one conversation snapshot. The instance registry reads former-name rows under the current name and, on its next write, saves every loaded row under it; transcripts, direct chats and stored graphs stay as written. - Resolve built-in configuration aliases before merging fields: `Raven-General` wins over `Raven`, then `raven`, regardless of file order. Discard older rows wholesale with a warning, preventing stale model, permission or transport settings from leaking into the selected row. - Resume the most recently written message state and instance log across former names. Saved messages take precedence over an empty chat directory; equal timestamps prefer the current name and then the most recent former name. Existing files stay in place. Legacy spawn records, completed DAG manifests and unfinished graphs remain readable through the current name. - Emit the agent roster once at the end of `spawn`'s description. The registry places `run_subagent_dag` and then `spawn` last, including after late MCP or session tools. The graph tool renders the roster itself when `spawn` is unavailable. With a Worker Table bound, dispatch guidance selects worker labels from the live enum; the roster explains underlying capabilities. The tool descriptions and resident DAG guide follow the same rule. - On a turn bound to a Worker Table, such as a Persona session, `spawn` and the DAG nodes offer worker labels alone, and a generated Persona never includes the generic agent. The host role on such a turn routes production work to the worker whose brief covers it, by label, and puts work no worker covers to the user, who can add a worker or give the conversation another Harness, instead of doing it itself or naming an agent outside the enum. Ordinary turns render byte for byte as before. A Harness that `load_playbook` binds mid-turn takes effect after the identity was assembled, so that call's result carries the same routing as this system's trusted note, after the untrusted fence. The coding skill picks worker labels on such a turn, for its first pick and for a quota takeover. ## Type - [ ] Fix - [x] Feature - [ ] Docs - [ ] CI / tooling - [ ] Refactor - [ ] Other ## Verification Measured at this head on Linux/Python 3.12.13. - `UV_NO_SYNC=1 uv run --no-sync pytest -q -n 12`: **33,767 passed, 178 skipped, 2 xfailed; 9 failed and 1 error.** Eight of the failures are bound to this box and fail the same way on current main, measured the same day: five provider tests that read the box's proxy environment, a Node.js path case, a LibreOffice conversion, and a fixture that root can read anyway. The ninth, with its teardown error, is the `remote_runs` race tracked in #990; that test passed 5 of 5 runs alone, and its file 58 of 58. - 13 new regression tests for Worker Table routing: 12 fail against the previous head's source and all pass now; the thirteenth checks that a Harness loaded mid-turn leaves the next turn's role plain, and passes on both by design. The end-to-end case drives a real Persona-bound turn: both enums offer `research-a` alone, dispatching `Raven-General` is refused, and the role must name neither that agent nor the roster fallback. - Nine single-construct mutants, each applied to an isolated copy of the tree, each fail at least one new test: the role ignoring the table, the default path not reading the turn's table, the uncovered-work rule removed, the generic fallback kept in the worker routing, the coding skill reverted, and the mid-turn note never added, added on every call, added without a dispatch path, or phrased apart from the role. - The host identity on ordinary turns is byte-identical to the previous head in all 16 rendered shapes: a launched sub-agent process or not, with or without ownership lines, and every combination of the two dispatch tools. - Instance registry probe, run with this head and with main on one synthetic file: reads leave the file byte-identical; one unrelated `upsert_spawn` saves every former-name row as `Raven-General`, keeping the more recently updated of two colliding spellings and the later one in the file on a tie; main then finds none of those rows under `Raven` or `raven`. - `uv run --no-sync python scripts/coverage_gate.py --coverage-json <coverage.json> diff --base-ref origin/main --threshold 90`, over a coverage run of 225 test files (8,952 passed): **99.40%**, 167/168 executable changed lines covered. - `UV_NO_SYNC=1 make lint-types lint-imports check-large-files check-source-language COMMIT_RANGE=origin/main...HEAD`: passed; all 10 import contracts kept. - `UV_NO_SYNC=1 make check-commits`: both commit-message validators passed; each also refused a dangling control commit with a malformed subject. - `ruff check` and `ruff format --check` over the branch's Python files passed. `node ui-tui/scripts/gen-i18n.mjs --check` passed after the rebase onto #1015, which also changed the i18n catalogue. - `uv run --no-sync pre-commit run --from-ref origin/main --to-ref HEAD`: every hook passed except the whole-TUI Prettier hook, which reports only `newInstancePicker.tsx` and `subagentsHub.tsx`; both are byte-identical to current main. - Live-model replay and native Windows/macOS testing were not repeated for these fixes. - [x] Relevant tests pass locally - [x] Relevant lint / type checks pass locally - [x] User-facing docs or screenshots are updated when needed ## Risk - The host delegates work it previously performed itself, including small scripts. Task-to-instance routing remains prompt-based; a task can still stay with the host after it has already answered a follow-up itself. - In a conversation bound to a Persona or another Harness with workers, work no worker's brief covers now waits for the user to add a worker or change the conversation's Harness, rather than being carried out by the host. - Old agent spellings remain accepted. The instance registry's first write after the upgrade, of any row for any session, saves every former-name row in `subagent_instances.json` as `Raven-General`, and keeps only the more recently updated row where two spellings of one instance collide. Builds from before the rename cannot look those rows up, so reverting the squash commit alone does not restore their instance bindings: that needs the registry file as it stood before that first write. Renaming rows back by hand cannot recover a colliding row the write dropped. Transcripts, direct chats and stored graphs are not rewritten. - When multiple generic-agent configuration spellings coexist, only the newest row contributes overrides. Fields supplied exclusively by an older row are intentionally discarded. - Moving the dispatch tools changes the tool-array cache prefix once after upgrade. - A plugin participant that removes `spawn` through `select_tools` can still leave the graph tool pointing at an absent roster, because that selection occurs after the registry's offer check. No bundled participant does this. - [x] Security impact considered - [x] Backward compatibility considered - [x] Rollback path is clear for risky changes ## Related Issues N/A
385 lines
17 KiB
Python
385 lines
17 KiB
Python
"""Orchestration tools are withheld from a loop the host launched as a sub-agent.
|
|
|
|
``RavenLoopBackend`` builds a sub-agent's registry from an empty ``ToolRegistry``
|
|
and never adds ``spawn`` or ``run_subagent_dag``, so an in-process sub-agent
|
|
cannot delegate. A ``kind: acp`` agent whose command is ``raven acp`` gets none of
|
|
that: the child is a separate process building its own full registry, and it
|
|
delegated a DAG node's whole task to a background ``spawn`` whose receipt returns
|
|
before any work is done -- twice, ending both turns with a promise instead of the
|
|
briefing the node was asked for.
|
|
|
|
The signal is an environment variable the host injects into every child it
|
|
launches, alongside the ``RAVEN_HOME`` it already sends. What the two paths
|
|
withhold is one shared set, asserted equal here so neither can drift.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import tempfile
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
from raven.agent.loop import AgentLoop
|
|
from raven.agent.subagent.backends.raven_loop import RavenLoopBackend
|
|
from raven.agent.subagent.role import WITHHELD_FROM_SUBAGENT
|
|
from raven.agent.tools.create_playbook import CreatePlaybookTool
|
|
from raven.agent.tools.load_playbook import LoadPlaybookTool
|
|
from raven.agent.tools.registry import ToolRegistry, absent_tool_error
|
|
from raven.config.schema import A2aConfig, A2aPeerConfig, PlaybookConfig
|
|
from raven.context_engine.segments import render
|
|
from raven.context_engine.segments.render import live_dispatch_tools
|
|
from raven.memory_engine import LocalSkillCatalog, filter_by_required_tools
|
|
from raven.providers.base import LLMProvider, LLMResponse
|
|
from tests._wiring import wire
|
|
|
|
|
|
class _StubProvider(LLMProvider):
|
|
def __init__(self) -> None:
|
|
super().__init__(api_key="test")
|
|
|
|
async def chat(
|
|
self,
|
|
messages,
|
|
tools=None,
|
|
model=None,
|
|
max_tokens=4096,
|
|
temperature=0.7,
|
|
reasoning_effort=None,
|
|
tool_choice=None,
|
|
):
|
|
return LLMResponse(content="stub", finish_reason="stop")
|
|
|
|
def get_default_model(self) -> str:
|
|
return "stub"
|
|
|
|
|
|
@pytest.fixture
|
|
def workspace():
|
|
with tempfile.TemporaryDirectory() as td:
|
|
yield Path(td)
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def _no_ambient_role(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
"""A developer whose shell exports the variable would otherwise see the
|
|
baseline half of every test below pass for the wrong reason."""
|
|
monkeypatch.delenv("RAVEN_SUBAGENT", raising=False)
|
|
|
|
|
|
def _loop(workspace: Path, **kw) -> AgentLoop:
|
|
return AgentLoop(provider=_StubProvider(), workspace=workspace, model="stub", **wire(**kw))
|
|
|
|
|
|
def _equipped_loop(workspace: Path) -> AgentLoop:
|
|
"""A loop holding every withheld name, so the gate has something to remove.
|
|
|
|
The two playbook tools arrive as plugin tools and unregister themselves when
|
|
the loop builds no funnel, so a bare loop never holds them and an assertion
|
|
that they are absent would pass over a loop that could not have had them.
|
|
`a2a_send` is the same shape for a different reason: it is registered only
|
|
with a peer configured, so a peerless loop could not have held it either.
|
|
"""
|
|
return _loop(
|
|
workspace,
|
|
playbook_config=PlaybookConfig(enabled=True),
|
|
plugin_tools=[LoadPlaybookTool(), CreatePlaybookTool()],
|
|
a2a_config=A2aConfig(peers=[A2aPeerConfig(origin="https://peer.example.com")]),
|
|
)
|
|
|
|
|
|
def test_subagent_mode_withholds_spawn(workspace, monkeypatch: pytest.MonkeyPatch) -> None:
|
|
# Unregistered rather than schema-hidden: ``_visible`` reads ``_tools``, so a
|
|
# hidden tool is still reachable through ``tool_call`` -- which is how
|
|
# ``resolve_dag_node`` is reached today.
|
|
ordinary = _loop(workspace)
|
|
assert ordinary.tools.has("spawn"), "baseline: an ordinary loop must hold spawn, or the gate proves nothing"
|
|
|
|
monkeypatch.setenv("RAVEN_SUBAGENT", "1")
|
|
delegated = _loop(workspace)
|
|
|
|
assert not delegated.tools.has("spawn")
|
|
|
|
|
|
def test_every_withheld_name_is_one_an_ordinary_loop_holds(workspace) -> None:
|
|
"""The constant names live tools, and the gate below is not asserting over
|
|
names nothing ever registers."""
|
|
ordinary = _equipped_loop(workspace)
|
|
|
|
missing = sorted(name for name in WITHHELD_FROM_SUBAGENT if not ordinary.tools.has(name))
|
|
|
|
assert not missing, f"{missing} is withheld from sub-agents but no ordinary loop registers it"
|
|
|
|
|
|
def test_subagent_mode_withholds_all_of_them(workspace, monkeypatch: pytest.MonkeyPatch) -> None:
|
|
monkeypatch.setenv("RAVEN_SUBAGENT", "1")
|
|
|
|
delegated = _equipped_loop(workspace)
|
|
|
|
still_held = sorted(name for name in WITHHELD_FROM_SUBAGENT if delegated.tools.has(name))
|
|
assert not still_held
|
|
assert delegated.tools.has("read_file"), "a sub-agent still has to do the work it was handed"
|
|
assert delegated.tools.has("message"), "message is deliberately not withheld over acp"
|
|
|
|
|
|
async def test_tool_call_cannot_reach_a_withheld_tool(workspace, monkeypatch: pytest.MonkeyPatch) -> None:
|
|
"""Why the gate unregisters rather than hides.
|
|
|
|
``hide_from_schema`` keeps a tool in ``_tools``, which is what ``_visible``
|
|
reads, so a hidden tool is still reachable by name -- that is how
|
|
``resolve_dag_node`` is reached today, and it would leave the gate open.
|
|
"""
|
|
monkeypatch.setenv("RAVEN_SUBAGENT", "1")
|
|
delegated = _equipped_loop(workspace)
|
|
forwarder = delegated.tools.get("tool_call")
|
|
assert forwarder is not None, "baseline: tool_call must exist, or nothing was tested"
|
|
|
|
answer = await forwarder.execute(name="run_subagent_dag", arguments={})
|
|
|
|
assert answer.startswith(absent_tool_error("run_subagent_dag")[:20])
|
|
|
|
|
|
def test_the_delegation_instruction_goes_with_the_tools(workspace, monkeypatch: pytest.MonkeyPatch) -> None:
|
|
"""The resident prompt must not keep telling a sub-agent to hand work over.
|
|
|
|
``## Delegation`` is the one segment that *prohibits* work, and
|
|
``_delegation_block`` already drops it when no dispatch path is live -- a
|
|
prohibition with no means of obeying it leaves the model choosing between
|
|
doing the forbidden thing and abandoning the task. That guard reads the
|
|
turn's real tool definitions, so the gate above is what empties it; asserted
|
|
here because the two live in different packages and nothing else connects
|
|
them.
|
|
"""
|
|
ordinary = _loop(workspace)
|
|
assert live_dispatch_tools(ordinary.tools.get_definitions), "baseline: an ordinary loop advertises a dispatch path"
|
|
|
|
monkeypatch.setenv("RAVEN_SUBAGENT", "1")
|
|
delegated = _loop(workspace)
|
|
|
|
assert live_dispatch_tools(delegated.tools.get_definitions) == ()
|
|
|
|
|
|
def test_the_prompt_tells_a_sub_agent_what_it_is(workspace, monkeypatch: pytest.MonkeyPatch) -> None:
|
|
"""Withholding the tools stops the delegating; it does not tell the child what
|
|
it is. An acp child otherwise renders the ordinary identity, which says nothing
|
|
about having been launched to work for another raven -- so it answers as an
|
|
agent that can still hand work on, and ends turns accordingly.
|
|
|
|
What the section may assert is bounded by the lane it cannot see; the test
|
|
below this one holds that boundary.
|
|
"""
|
|
plain = render.identity_text(workspace)
|
|
assert "## Sub-agent" not in plain
|
|
|
|
monkeypatch.setenv("RAVEN_SUBAGENT", "1")
|
|
delegated = render.identity_text(workspace)
|
|
|
|
assert "## Sub-agent" in delegated
|
|
assert delegated.index("## Sub-agent") < delegated.index("## Raven Guidelines"), (
|
|
"a rule about what the whole turn is for has to be read before the guidelines it qualifies"
|
|
)
|
|
|
|
|
|
def test_the_orchestration_guide_goes_with_the_tools(workspace, monkeypatch: pytest.MonkeyPatch) -> None:
|
|
"""The DAG guide is an ``always`` skill, so it is resident unconditionally --
|
|
and it declares ``requires.tools: [run_subagent_dag]``.
|
|
|
|
``ActiveSkillsSegmentBuilder._require_tools`` already drops an always-skill
|
|
whose tools are not registered, reading the turn's live definitions, so the
|
|
gate above is what empties it. Measured rather than assumed: the filter
|
|
stands one package away and fails open when it cannot see a tool table.
|
|
"""
|
|
catalog = LocalSkillCatalog(workspace)
|
|
always = catalog.get_always_skills()
|
|
assert always, "baseline: the shipped catalog must carry an always-skill, or this asserts nothing"
|
|
|
|
ordinary = _loop(workspace)
|
|
kept = filter_by_required_tools(always, render.collect_tool_names(ordinary.tools.get_definitions))
|
|
assert kept, "baseline: an ordinary loop keeps the guide"
|
|
|
|
monkeypatch.setenv("RAVEN_SUBAGENT", "1")
|
|
delegated = _loop(workspace)
|
|
|
|
withheld = filter_by_required_tools(always, render.collect_tool_names(delegated.tools.get_definitions))
|
|
assert withheld == []
|
|
|
|
|
|
def test_the_sub_agent_note_claims_nothing_about_who_is_reading(workspace, monkeypatch: pytest.MonkeyPatch) -> None:
|
|
"""One pooled acp connection serves every call to an agent, so the same process
|
|
answers a dispatched DAG node and a person's direct chat.
|
|
|
|
``acp_client/pool.py`` keys a connection on the launch config, and the role is
|
|
applied at launch, so it cannot tell the two apart. A note asserting that the
|
|
reply goes to an agent rather than a person, or that no turn follows, is
|
|
therefore false on the direct-chat lane -- where the reply streams to the person
|
|
and the instance stays available for the next turn. The note may claim what this
|
|
process holds and what happens when its turn ends; those hold either way.
|
|
"""
|
|
monkeypatch.setenv("RAVEN_SUBAGENT", "1")
|
|
note = render.identity_text(workspace)
|
|
assert "## Sub-agent" in note, "baseline: the section must be present, or this asserts nothing"
|
|
|
|
section = note.split("## Sub-agent", 1)[1].split("\n##", 1)[0].lower()
|
|
|
|
for lane_dependent in ("not shown to a person", "nothing follows this turn", "is waiting on your"):
|
|
assert lane_dependent not in section, (
|
|
f"the note claims {lane_dependent!r}, which is false when a person is in a direct chat with this agent"
|
|
)
|
|
|
|
|
|
def test_the_sub_agent_note_leaves_room_for_scheduled_delivery(workspace, monkeypatch: pytest.MonkeyPatch) -> None:
|
|
"""A flat "nothing runs after your turn ends" is false in an acp process.
|
|
|
|
``WiringMixin`` registers ``cron`` whenever a cron service exists, and
|
|
``build_rpc_stack`` starts one for this channel with ``make_on_session_wake``
|
|
so a fired job runs later on the session that armed it. Telling the model
|
|
otherwise would call its own scheduled reminder worthless. The qualifier is
|
|
what the section turns on, so the qualifier is what is asserted -- banning a
|
|
phrasing would pass over the next absolute sentence written a different way.
|
|
"""
|
|
monkeypatch.setenv("RAVEN_SUBAGENT", "1")
|
|
note = render.identity_text(workspace)
|
|
section = note.split("## Sub-agent", 1)[1].split("\n##", 1)[0].lower()
|
|
|
|
about_the_end = [line for line in section.splitlines() if "your turn ends" in line]
|
|
assert about_the_end, "baseline: the section must say something about what follows the turn"
|
|
|
|
assert all("unless" in line for line in about_the_end), (
|
|
"an unqualified claim that nothing runs after the turn contradicts cron, which this "
|
|
"process holds and which does deliver later"
|
|
)
|
|
|
|
|
|
def test_the_ordinary_prompt_is_byte_identical_without_the_role(workspace, monkeypatch: pytest.MonkeyPatch) -> None:
|
|
"""The joint, not just the section: the delegation block above this one once
|
|
rendered a prompt one blank line short on every install without a specialist,
|
|
and a test comparing the function against itself agreed with it."""
|
|
monkeypatch.delenv("RAVEN_SUBAGENT", raising=False)
|
|
|
|
plain = render.identity_text(workspace)
|
|
|
|
assert "\n\n\n## Raven Guidelines" in plain
|
|
|
|
|
|
def test_the_reply_rules_are_the_host_s_alone(workspace, monkeypatch: pytest.MonkeyPatch) -> None:
|
|
"""The host's reader gets the reply rules; a launched child does not.
|
|
|
|
The agents under ``agents/`` render this identity too, and each carries its own
|
|
conduct for how it reports, so the section stays out of any process the host
|
|
launched to work for it.
|
|
"""
|
|
plain = render.identity_text(workspace)
|
|
assert "## How you reply" in plain
|
|
assert plain.index("## Raven Guidelines") < plain.index("## How you reply")
|
|
|
|
monkeypatch.setenv("RAVEN_SUBAGENT", "1")
|
|
assert "## How you reply" not in render.identity_text(workspace)
|
|
|
|
|
|
def test_the_manager_role_is_the_host_s_alone(workspace, monkeypatch: pytest.MonkeyPatch) -> None:
|
|
"""A launched child does the work it was handed. Telling it that it runs the
|
|
work through a roster would contradict the registry it was given, which holds
|
|
no tool that hands work on -- so the child keeps the identity it had before.
|
|
|
|
Asserted with ``identity_text``'s default dispatch paths on purpose: the role
|
|
has to follow the process, not only the tool table it is told about.
|
|
"""
|
|
plain = render.identity_text(workspace)
|
|
assert "## Your role" in plain
|
|
|
|
monkeypatch.setenv("RAVEN_SUBAGENT", "1")
|
|
child = render.identity_text(workspace)
|
|
|
|
assert "## Your role" not in child
|
|
assert "You are Raven, a helpful AI assistant." in child
|
|
|
|
|
|
def test_the_reply_rules_leave_one_blank_line_either_side(workspace, monkeypatch: pytest.MonkeyPatch) -> None:
|
|
"""The joint in both roles. The section is spliced in by a helper that renders
|
|
empty for a child, and a stray newline on either branch would ship unseen in
|
|
every prompt of that role."""
|
|
plain = render.identity_text(workspace)
|
|
assert "\n\n## How you reply\n" in plain
|
|
assert "\n\n\n## How you reply" not in plain
|
|
assert "overrides them.\n\nReply directly" in plain
|
|
|
|
monkeypatch.setenv("RAVEN_SUBAGENT", "1")
|
|
delegated = render.identity_text(workspace)
|
|
assert "\n\nReply directly" in delegated
|
|
assert "\n\n\nReply directly" not in delegated
|
|
|
|
|
|
def test_the_reply_rules_do_not_choose_the_reply_language(workspace, monkeypatch: pytest.MonkeyPatch) -> None:
|
|
"""One English section serves both reply languages. On a zh install the
|
|
language line has to survive above it, and the section has to say it does not
|
|
decide the language, or English rules read as a request for English."""
|
|
from raven import i18n
|
|
|
|
monkeypatch.setattr(i18n, "_language", "zh")
|
|
plain = render.identity_text(workspace)
|
|
|
|
assert "Always respond in" in plain
|
|
assert plain.index("Always respond in") < plain.index("## How you reply")
|
|
section = plain.split("## How you reply", 1)[1].split("\n\nReply directly", 1)[0]
|
|
assert "not which language you write in" in section
|
|
|
|
|
|
def test_both_sub_agent_paths_withhold_the_same_tools(workspace, monkeypatch: pytest.MonkeyPatch) -> None:
|
|
"""The drift lock between the in-process backend and an acp child.
|
|
|
|
``RavenLoopBackend`` withholds by never registering into a registry it builds
|
|
itself; the acp child withholds by the gate this module adds. Neither reads
|
|
the other, so what they withhold is asserted equal rather than assumed.
|
|
|
|
Each side is measured as what it ends up *holding*, which is the thing a model
|
|
can reach. The two are observed differently only because the backend keeps no
|
|
reference to the registry it builds inside ``run``: a ``register`` spy is the
|
|
only way to see it. Reading the spy as the acp side's answer too would be
|
|
wrong -- the playbook tools are registered as plugin tools and unregister
|
|
themselves when they decline, so they appear in a registration log they are
|
|
absent from the registry for.
|
|
"""
|
|
registered: list[str] = []
|
|
real = ToolRegistry.register
|
|
|
|
def _spy(self, tool): # noqa: ANN001, ANN202
|
|
real(self, tool)
|
|
registered.append(tool.name)
|
|
|
|
monkeypatch.setattr(ToolRegistry, "register", _spy)
|
|
|
|
async def _run_builtin() -> None:
|
|
backend = RavenLoopBackend(provider=_StubProvider(), model="stub", agent_home=workspace / "home")
|
|
await backend.run("task", task_id="t1", workspace=workspace, executor=None)
|
|
|
|
import asyncio
|
|
|
|
asyncio.run(_run_builtin())
|
|
builtin = set(registered)
|
|
|
|
monkeypatch.setenv("RAVEN_SUBAGENT", "1")
|
|
delegated = _equipped_loop(workspace)
|
|
|
|
assert "read_file" in builtin and delegated.tools.has("read_file"), "baseline: neither side may be empty"
|
|
over_acp = {name for name in WITHHELD_FROM_SUBAGENT if delegated.tools.has(name)}
|
|
assert WITHHELD_FROM_SUBAGENT & builtin == over_acp == set()
|
|
|
|
|
|
def test_a2a_send_is_withheld_from_a_subagent(monkeypatch):
|
|
from raven.agent.subagent.role import WITHHELD_FROM_SUBAGENT, is_subagent_process
|
|
|
|
monkeypatch.setenv("RAVEN_SUBAGENT", "1")
|
|
assert is_subagent_process() is True
|
|
assert "a2a_send" in WITHHELD_FROM_SUBAGENT
|
|
|
|
|
|
def test_a2a_send_is_registered_only_with_a_peer_configured(workspace) -> None:
|
|
"""The outbound tool is not free: its schema is reserved on every turn of
|
|
every conversation, and a host with no peers has nowhere to send a message.
|
|
The five product launcher tests pin the absent half from the other end.
|
|
"""
|
|
assert not _loop(workspace, a2a_config=A2aConfig()).tools.has("a2a_send")
|
|
|
|
with_peer = A2aConfig(peers=[A2aPeerConfig(origin="https://peer.example.com")])
|
|
assert _loop(workspace, a2a_config=with_peer).tools.has("a2a_send")
|