Skip to content

Commit

Permalink
Remove echo if command
Browse files Browse the repository at this point in the history
  • Loading branch information
rusiaaman committed Feb 12, 2025
1 parent 557b66a commit 643848d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 25 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[project]
authors = [{ name = "Aman Rusia", email = "[email protected]" }]
name = "wcgw"
version = "3.0.1rc2"
version = "3.0.1rc3"
description = "Shell and coding agent on claude and chatgpt"
readme = "README.md"
requires-python = ">=3.11"
Expand Down
10 changes: 9 additions & 1 deletion src/wcgw/client/bash_state/bash_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -681,9 +681,17 @@ def execute_bash(
timeout_s: Optional[float],
) -> tuple[str, float]:
try:
return _execute_bash(bash_state, enc, bash_arg, max_tokens, timeout_s)
output, cost = _execute_bash(bash_state, enc, bash_arg, max_tokens, timeout_s)

# Remove echo if it's a command
if isinstance(bash_arg.action, Command):
command = bash_arg.action.command.strip()
if output.startswith(command):
output = output[len(command) :]

finally:
bash_state.run_bg_expect_thread()
return output, cost


def _execute_bash(
Expand Down
30 changes: 8 additions & 22 deletions tests/test_mcp_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,6 @@
@pytest.fixture(scope="function", autouse=True)
def setup_bash_state():
"""Setup BashState for each test"""
# Reset server.BASH_STATE
if server.BASH_STATE:
try:
server.BASH_STATE.close_bg_expect_thread()
server.BASH_STATE.cleanup()
except:
pass
server.BASH_STATE = None

# Update CONFIG immediately
CONFIG.update(3, 55, 5)
Expand All @@ -53,17 +45,11 @@ def setup_bash_state():
try:
yield server.BASH_STATE
finally:
if server.BASH_STATE:
try:
server.BASH_STATE.close_bg_expect_thread()
server.BASH_STATE.cleanup()
except Exception as e:
print(f"Error during cleanup: {e}")
server.BASH_STATE = None
# Sleep a bit to allow cleanup to complete
import time

time.sleep(0.1)
try:
bash_state.cleanup()
except Exception as e:
print(f"Error during cleanup: {e}")
server.BASH_STATE = None


@pytest.mark.asyncio
Expand Down Expand Up @@ -132,9 +118,9 @@ async def test_handle_list_tools():
"FileEdit",
"ContextSave",
}
assert required_tools.issubset(tool_names), (
f"Missing tools: {required_tools - tool_names}"
)
assert required_tools.issubset(
tool_names
), f"Missing tools: {required_tools - tool_names}"

# Test each tool's schema and description
for tool in tools:
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 643848d

Please sign in to comment.