diff --git a/cli/internal/acp/server.go b/cli/internal/acp/server.go index 8e2b2ae06..dc9445863 100644 --- a/cli/internal/acp/server.go +++ b/cli/internal/acp/server.go @@ -208,7 +208,7 @@ func (a *adapter) setup(message request) { SessionID string `json:"sessionId"` MCPServers []json.RawMessage `json:"mcpServers"` } - if decodeParams(message.Params, ¶ms) != nil || !filepath.IsAbs(params.Cwd) || params.MCPServers == nil { + if decodeParams(message.Params, ¶ms) != nil || !filepath.IsAbs(params.Cwd) || params.MCPServers == nil && message.Method != "session/resume" { a.respond(message.ID, nil, problem(-32602, "invalid_params", "cwd must be absolute and mcpServers must be an array")) return } @@ -216,10 +216,16 @@ func (a *adapter) setup(message request) { for _, raw := range params.MCPServers { var fields map[string]json.RawMessage var server protocol.ACPMCPServer - if json.Unmarshal(raw, &fields) != nil || fields["type"] != nil || json.Unmarshal(raw, &server) != nil || server.Name == "" || !filepath.IsAbs(server.Command) || server.Args == nil || server.Env == nil { + if json.Unmarshal(raw, &fields) != nil || fields["type"] != nil || json.Unmarshal(raw, &server) != nil || server.Name == "" || !filepath.IsAbs(server.Command) || fields["args"] == nil || fields["env"] == nil { a.respond(message.ID, nil, problem(-32602, "invalid_params", "Only valid stdio MCP servers are supported")) return } + if server.Args == nil { + server.Args = []string{} + } + if server.Env == nil { + server.Env = []protocol.ACPEnvVariable{} + } servers = append(servers, server) } if message.Method != "session/new" && !fullID(params.SessionID) { diff --git a/robot-docs/acp.md b/robot-docs/acp.md index e7bf92b38..e59d756b1 100644 --- a/robot-docs/acp.md +++ b/robot-docs/acp.md @@ -26,7 +26,7 @@ New, loaded, and resumed sessions return a `configOptions` model selector with ` `session/set_config_option` accepts `configId: "model"` and an advertised value. Switching requires an idle session, affects only that session, and rechecks attachment ownership inside the daemon actor. Resume refreshes choices and the current selection. -`session/list` discovers ACP sessions without acquiring ownership. It supports an exact `cwd` filter and opaque pagination. Load and resume require full session IDs, matching workspaces, and the intended MCP configuration. Competing writers cannot attach. +`session/list` discovers ACP sessions without acquiring ownership. It supports an exact `cwd` filter and opaque pagination. Load and resume require full session IDs, matching workspaces, and the intended MCP configuration. Resume defaults an omitted or null `mcpServers` to an empty list. Stdio server `args` and `env` remain required, but null values default to empty lists. These defaults follow `ResumeSessionRequest` and `McpServerStdio` in the [pinned ACP schema](../cli/internal/acp/testdata/acp-schema-v1.27.0.json). Competing writers cannot attach. Load replays durable user messages, replies, thoughts, and tools in order, then delivers buffered live activity. History pages follow the daemon's opaque `newer` token, including entries that share the cutoff row's position. It excludes internal provider records and system input. Replay failure returns an error and releases the attachment. Resume delivers future activity without replay. Resuming running work permits cancellation and holds one successor prompt until the inherited work ends. Further prompts return busy while that slot is occupied. diff --git a/test/e2e/acp_test.py b/test/e2e/acp_test.py index 131245429..f5ade06d6 100644 --- a/test/e2e/acp_test.py +++ b/test/e2e/acp_test.py @@ -1189,6 +1189,29 @@ class AcpAttachmentTests(AcpSessionCase): -32002, ) + def test_resume_accepts_an_omitted_or_null_mcp_server_list(self): + client = self.connect() + self.initialize(client) + session = self.new_session(client) + for optional in ({}, {"mcpServers": None}): + with self.subTest(optional=optional): + self.result( + client.request( + "session/resume", + { + "sessionId": session, + "cwd": str(self.workspace), + **optional, + }, + ) + ) + self.assertEqual( + self.stop_reason( + self.prompt(client, session, text_block("resumed")) + ), + "end_turn", + ) + def test_resume_of_an_idle_session_accepts_a_new_prompt(self): self.script = lambda request: text("first answer") first = self.connect() @@ -1384,6 +1407,32 @@ class AcpMcpTests(AcpSessionCase): else text("done") ) + def test_stdio_server_accepts_null_args_and_env(self): + client = self.connect() + self.initialize(client) + session = self.new_session( + client, + servers=[ + { + "name": "overlay", + "command": str(overlay_server(self.app.root)), + "args": None, + "env": None, + } + ], + ) + self.call_overlay_tool() + self.assertEqual( + self.stop_reason(self.prompt(client, session, text_block("call tool"))), + "end_turn", + ) + self.assertTrue( + any( + name.startswith("mcp_overlay") + for name in tool_names(self.provider.requests[0]["request"]) + ) + ) + def test_prompt_after_failed_reattach_returns_the_resume_remedy(self): client = self.connect() self.initialize(client)