test(multi-agent): end-to-end integration coverage#462
Merged
Conversation
…d PRs Adds `tests/test_multi_agent_integration.py` — eight cases that exercise the full MCP tool surface (`mem_agent_register` / `mem_search` / `mem_agent_search` / `mem_agent_share` / `mem_session_start`) and the LangGraph adapter against a real BM25-only component stack. The unit tests in `test_multi_agent.py` and `test_sessions.py` already pin each helper's contract in isolation; this file checks that the four pieces compose end-to-end without silently regressing. Cases: * **A — namespace isolation** (PR-1, #457): `agent-runtime:alpha` chunks excluded from `mem_search` for an agent-blind caller; `mem_agent_search(agent_id="alpha")` reaches them by pinning the namespace explicitly. * **B — share trail** (PR-3, #458): `mem_agent_share(target="shared")` lands a copy in the shared namespace with the `shared-from=<source-uuid>` audit trail; the receiving agent's `mem_agent_search(include_shared=True)` surfaces the copy and `include_shared=False` correctly excludes it. * **C — session→agent_id inheritance** (PR-2, #459): `mem_session_start(agent_id="planner")` lets a subsequent `mem_agent_search(agent_id=None)` resolve to the planner's namespace + shared without the caller repeating the identity; explicit `agent_id` overrides the session binding. * **D — LangGraph adapter** (PR-4, #460): `MemtomemStore.start_agent_session("planner")` defaults `add()` writes to `agent-runtime:planner` and gates `search(include_shared=True)` to planner+shared (excluding other agents' private chunks); `include_shared=True` without a bound agent raises `ValueError`. Discovery during testing — a follow-up to track: * `mem_agent_share` calls `mem_add`, which writes tags into the markdown blockquote header (`> tags: [...]`) instead of YAML frontmatter. The indexer extracts only YAML frontmatter, so the audit tag (`shared-from=<uuid>`) lives in the chunk *content* and not in `ChunkMetadata.tags` — searchable by BM25 but not by `tag_filter`. Promoting the blockquote header to first-class metadata is tracked as a follow-up RFC; the test asserts the tag in `chunk.content` and documents the constraint inline. `uv run pytest -m "not ollama"` — 2384 passed, 46 deselected. Co-Authored-By: Claude <[email protected]>
* Extract the ``MEMTOMEM_*`` env-var clear + ``load_config_overrides`` stub into a module-level ``_isolate_memtomem_env`` helper instead of duplicating it across the fixture and the two LangGraph adapter tests. Adding a new top-level config section's env binding now means editing one tuple, not three. * Drop the ``assert SHARED_NAMESPACE in share_out`` check on the ``mem_agent_share`` return string — the storage-side inspection that follows is the strong assertion, and pinning the cosmetic return-string format makes the test brittle for no extra coverage. * Expand the comment on the ``store._ensure_init()`` reach-through in the LangGraph adapter test to spell out *why* internal access is necessary (no public ``namespace=`` override on ``store.add`` for writing outside the bound agent), so a future reader doesn't try to rewrite the seeding step against the public surface. Co-Authored-By: Claude <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
tests/test_multi_agent_integration.py— eight end-to-end casesthat exercise the full MCP tool surface (
mem_agent_register/mem_search/mem_agent_search/mem_agent_share/mem_session_start) and the LangGraph adapter against a realBM25-only component stack.
The unit tests in
test_multi_agent.pyandtest_sessions.pyalreadypin each helper's contract in isolation (
_resolve_agent_namespacepriority table,
_build_shared_tagsdedup invariant,_resolve_search_namespace6-case matrix); this file checks that thefour pieces compose end-to-end without silently regressing.
Cases
agent-runtime:alphachunks excluded from
mem_searchfor an agent-blind caller;mem_agent_search(agent_id="alpha")reaches them.mem_agent_share(target="shared")copies the chunk into the shared namespace with the
shared-from=<source-uuid>audit tag; receiving agent'smem_agent_search(include_shared=True)surfaces the copy andinclude_shared=Falsecorrectly excludes it.mem_session_start(agent_id="planner")lets a subsequentmem_agent_search(agent_id=None)resolve to the planner'snamespace + shared without the caller repeating the identity;
explicit
agent_idoverrides the session binding.MemtomemStore.start_agent_session("planner")defaultsadd()toagent-runtime:plannerand gatessearch(include_shared=True)toplanner+shared (excluding other agents' private chunks);
include_shared=Truewithout a bound agent raisesValueError.Discovery — follow-up to track
mem_agent_sharecallsmem_add, which writes tags into the markdownblockquote header (
> tags: [...]) instead of YAML frontmatter. Theindexer extracts only YAML frontmatter, so the audit tag
(
shared-from=<uuid>) lives in the chunk content and not inChunkMetadata.tags— searchable by BM25 but not bytag_filter.Promoting the blockquote header to first-class metadata is tracked
as a follow-up RFC; the test asserts the tag in
chunk.contentwitha docstring noting the constraint.
Test plan
uv run pytest packages/memtomem/tests/test_multi_agent_integration.py -v— 8/8 pass.uv run pytest -m "not ollama"— 2384 passed, 46 deselected.uv run ruff check+ruff format --check— clean.🤖 Generated with Claude Code