()
| 623 | |
| 624 | @pytest.mark.asyncio |
| 625 | async def test_session_auto_creation(): |
| 626 | |
| 627 | class RunnerWithMismatch(Runner): |
| 628 | |
| 629 | def _infer_agent_origin( |
| 630 | self, agent: BaseAgent |
| 631 | ) -> tuple[Optional[str], Optional[Path]]: |
| 632 | del agent |
| 633 | return "expected_app", Path("/workspace/agents/expected_app") |
| 634 | |
| 635 | session_service = InMemorySessionService() |
| 636 | runner = RunnerWithMismatch( |
| 637 | app_name="expected_app", |
| 638 | agent=MockLlmAgent("test_agent"), |
| 639 | session_service=session_service, |
| 640 | artifact_service=InMemoryArtifactService(), |
| 641 | auto_create_session=True, |
| 642 | ) |
| 643 | |
| 644 | agen = runner.run_async( |
| 645 | user_id="user", |
| 646 | session_id="missing", |
| 647 | new_message=types.Content(role="user", parts=[types.Part(text="hi")]), |
| 648 | ) |
| 649 | |
| 650 | event = await agen.__anext__() |
| 651 | await agen.aclose() |
| 652 | |
| 653 | # Verify that session_id="missing" doesn't error out - session is auto-created |
| 654 | assert event.author == "test_agent" |
| 655 | assert event.content.parts[0].text == "Test LLM response" |
| 656 | |
| 657 | |
| 658 | @pytest.mark.asyncio |
nothing calls this directly
no test coverage detected