From 6a9b72e5b30acbda476aa6410ee823d258109fd9 Mon Sep 17 00:00:00 2001 From: Quinlan Jager Date: Sat, 3 May 2025 00:15:35 -0700 Subject: [PATCH] Set a tool_call_limit of 25 --- aider/coders/base_coder.py | 8 ++++- aider/gui.py | 1 - aider/website/docs/config/mcp.md | 52 ++++++++++++++------------------ 3 files changed, 29 insertions(+), 32 deletions(-) diff --git a/aider/coders/base_coder.py b/aider/coders/base_coder.py index 6d0279eee..f926e42e8 100755 --- a/aider/coders/base_coder.py +++ b/aider/coders/base_coder.py @@ -92,6 +92,8 @@ class Coder: last_keyboard_interrupt = None num_reflections = 0 max_reflections = 3 + num_tool_calls = 0 + max_tool_calls = 25 edit_format = None yield_stream = False temperature = None @@ -1475,7 +1477,8 @@ class Coder: tool_call_response = litellm.stream_chunk_builder(self.partial_response_tool_call) - if tool_call_response: + if tool_call_response and self.num_tool_calls < self.max_tool_calls: + self.num_tool_calls += 1 tool_responses = self.execute_tool_calls(tool_call_response) # Add the assistant message with tool calls @@ -1487,7 +1490,10 @@ class Coder: self.cur_messages.append(tool_response) return self.run(with_message="Continue", preproc=False) + elif self.num_tool_calls >= self.max_tool_calls: + self.io.tool_warning(f"Only {self.max_tool_calls} tool calls allowed, stopping.") + self.tool_call_limit = 0 try: if self.reply_completed(): return diff --git a/aider/gui.py b/aider/gui.py index 23e59520d..7fa90bc38 100755 --- a/aider/gui.py +++ b/aider/gui.py @@ -198,7 +198,6 @@ class GUI: ) for fname in fnames: - print(fname) if fname not in self.coder.get_inchat_relative_files(): self.coder.add_rel_fname(fname) self.info(f"Added {fname} to the chat") diff --git a/aider/website/docs/config/mcp.md b/aider/website/docs/config/mcp.md index 8916ddbab..2d49227bb 100644 --- a/aider/website/docs/config/mcp.md +++ b/aider/website/docs/config/mcp.md @@ -16,36 +16,10 @@ for more information. You have two ways of sharing your MCP server configuration with Aider. -### 1. Using a JSON string +{: .note } +Today, Aider only supports connecting to MCP servers using the stdio transport -You can specify MCP servers directly on the command line using the `--mcp-servers` option with a JSON string: - -```bash -aider --mcp-servers '{"mcpServers":{"git":{"command":"uvx","args":["mcp-server-git"]}}}' -``` - -### 2. Using a configuration file - -Alternatively, you can store your MCP server configurations in a JSON file and reference it with the `--mcp-servers-file` option: - -```bash -aider --mcp-servers-file mcp.json -``` - -Example `mcp.json` file: - -```json -{ - "mcpServers": { - "git": { - "command": "uvx", - "args": ["mcp-server-git"] - } - } -} -``` - -## YAML Configuration +### Config Files You can also configure MCP servers in your `.aider.conf.yml` file: @@ -69,7 +43,25 @@ mcp-servers-file: /path/to/mcp.json These options are configurable in any of Aider's config file formats. -## Environment Variables +### Flags + +You can specify MCP servers directly on the command line using the `--mcp-servers` option with a JSON string: + +#### Using a JSON String + +```bash +aider --mcp-servers '{"mcpServers":{"git":{"command":"uvx","args":["mcp-server-git"]}}}' +``` + +#### Using a configuration file + +Alternatively, you can store your MCP server configurations in a JSON file and reference it with the `--mcp-servers-file` option: + +```bash +aider --mcp-servers-file mcp.json +``` + +### Environment Variables You can also configure MCP servers using environment variables in your `.env` file: