fix: Remove 'per_agent' from kwargs when using remote session service URIs

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 837169299
This commit is contained in:
George Weale
2025-11-26 10:08:13 -08:00
committed by Copybara-Service
parent ec4ccd718f
commit 73e5687b9a
6 changed files with 10 additions and 82 deletions
+3 -16
View File
@@ -300,13 +300,11 @@ def test_create_artifact_service_defaults_to_file(tmp_path: Path) -> None:
assert expected_root.exists()
def test_create_artifact_service_per_agent_uses_shared_root(
def test_create_artifact_service_uses_shared_root(
tmp_path: Path,
) -> None:
"""Multi-agent mode should still use a single file artifact service."""
service = create_artifact_service_from_options(
base_dir=tmp_path, per_agent=True
)
"""Artifact service should use a single file artifact service."""
service = create_artifact_service_from_options(base_dir=tmp_path)
assert isinstance(service, FileArtifactService)
expected_root = Path(tmp_path) / ".adk" / "artifacts"
assert service.root_dir == expected_root
@@ -332,17 +330,6 @@ def test_create_artifact_service_accepts_file_uri(tmp_path: Path) -> None:
assert custom_root.exists()
def test_create_artifact_service_file_uri_rejects_per_agent(tmp_path: Path):
"""file:// URIs are incompatible with per-agent mode."""
custom_root = tmp_path / "custom"
with pytest.raises(ValueError, match="multi-agent"):
create_artifact_service_from_options(
base_dir=tmp_path,
artifact_service_uri=custom_root.as_uri(),
per_agent=True,
)
@pytest.mark.asyncio
async def test_run_cli_accepts_memory_scheme(
fake_agent, tmp_path: Path
@@ -41,35 +41,12 @@ def test_create_session_service_uses_registry(tmp_path: Path, monkeypatch):
registry.create_session_service.assert_called_once_with(
"sqlite:///test.db",
agents_dir=str(tmp_path),
per_agent=False,
)
def test_create_session_service_per_agent_uri(tmp_path: Path, monkeypatch):
registry = Mock()
expected = object()
registry.create_session_service.return_value = expected
monkeypatch.setattr(service_factory, "get_service_registry", lambda: registry)
result = service_factory.create_session_service_from_options(
base_dir=tmp_path,
session_service_uri="memory://",
per_agent=True,
)
assert result is expected
registry.create_session_service.assert_called_once_with(
"memory://", agents_dir=str(tmp_path), per_agent=True
)
@pytest.mark.parametrize("per_agent", [True, False])
def test_create_session_service_defaults_to_memory(
tmp_path: Path, per_agent: bool
):
def test_create_session_service_defaults_to_memory(tmp_path: Path):
service = service_factory.create_session_service_from_options(
base_dir=tmp_path,
per_agent=per_agent,
)
assert isinstance(service, InMemorySessionService)
@@ -94,15 +71,11 @@ def test_create_session_service_fallbacks_to_database(
registry.create_session_service.assert_called_once_with(
"sqlite+aiosqlite:///:memory:",
agents_dir=str(tmp_path),
per_agent=False,
echo=True,
)
@pytest.mark.parametrize("per_agent", [True, False])
def test_create_artifact_service_uses_registry(
tmp_path: Path, monkeypatch, per_agent: bool
):
def test_create_artifact_service_uses_registry(tmp_path: Path, monkeypatch):
registry = Mock()
expected = object()
registry.create_artifact_service.return_value = expected
@@ -111,14 +84,12 @@ def test_create_artifact_service_uses_registry(
result = service_factory.create_artifact_service_from_options(
base_dir=tmp_path,
artifact_service_uri="gs://bucket/path",
per_agent=per_agent,
)
assert result is expected
registry.create_artifact_service.assert_called_once_with(
"gs://bucket/path",
agents_dir=str(tmp_path),
per_agent=per_agent,
)