diff --git a/mini_agent/acp/__init__.py b/mini_agent/acp/__init__.py index b794e451..5a2b3c68 100644 --- a/mini_agent/acp/__init__.py +++ b/mini_agent/acp/__init__.py @@ -108,7 +108,12 @@ async def prompt(self, params: PromptRequest) -> PromptResponse: if not state: # Auto-create session if not found (compatibility with clients that skip newSession) logger.warning(f"Session '{params.sessionId}' not found, auto-creating new session") - new_session = await self.newSession(NewSessionRequest(cwd=None)) + new_session = await self.newSession( + NewSessionRequest( + cwd=str(self._config.agent.workspace_dir), + mcpServers=[], + ) + ) state = self._sessions.get(new_session.sessionId) if not state: logger.error("Failed to auto-create session") diff --git a/tests/test_acp.py b/tests/test_acp.py index c0fd3794..608c7c6a 100644 --- a/tests/test_acp.py +++ b/tests/test_acp.py @@ -1,5 +1,6 @@ """Integration tests for the MiniMax ACP adapter.""" +from pathlib import Path from types import SimpleNamespace import pytest @@ -82,8 +83,11 @@ async def test_acp_turn_executes_tool(acp_agent): @pytest.mark.asyncio -async def test_acp_invalid_session(acp_agent): +async def test_acp_unknown_session_auto_creates_with_configured_workspace(acp_agent): agent, _ = acp_agent prompt = SimpleNamespace(sessionId="missing", prompt=[{"text": "?"}]) response = await agent.prompt(prompt) - assert response.stopReason == "refusal" + assert response.stopReason == "end_turn" + assert len(agent._sessions) == 1 + created_session = next(iter(agent._sessions.values())) + assert Path(created_session.agent.workspace_dir) == Path(agent._config.agent.workspace_dir)