Self-improving AI Employees for everyone
Python ai-agentsai-employeeai-employeesassistantautonomous-agentsco-employeescompanygrok-botinstinctloop-agentsmuseown-your-datapersonalself-hosted
fix(cli_agent): pywinpty bytes->str decode at Windows PTY boundary + drop tools-directive prepend
trohitg2609dfff03d3
diff --git a/server/services/cli_agent/providers/anthropic_claude.py b/server/services/cli_agent/providers/anthropic_claude.pyindex 5a7aa2e1..c049c647 100644--- a/server/services/cli_agent/providers/anthropic_claude.py+++ b/server/services/cli_agent/providers/anthropic_claude.py@@ -256,29 +256,6 @@ class AnthropicClaudeProvider:len(task.system_prompt), task.system_prompt[:200],)- # Connected-tools steering directive — ensures the agent prefers- # wired MCP tools over built-in escape hatches (WebSearch,- # WebFetch, Bash) when their purpose matches the user's request.- # Mirrors Cursor's per-request rule prepend pattern- # (https://cursor.com/docs/rules). Multiple `--append-system-prompt`- # flags concatenate per the CLI reference.- if connected_tool_names:- tool_list = ", ".join(- f"mcp__machinaos__{name}" for name in connected_tool_names- )- directive = (- f"Workflow tools wired to this agent: {tool_list}. "- "Prefer them over built-in equivalents (WebSearch, "- "WebFetch, Bash) when the user's request matches their "- "purpose."- )- argv += ["--append-system-prompt", directive]- logger.info(- "[CC-Agent argv] --append-system-prompt (tools-directive) "- "length=%d",- len(directive),- )-# Optional per-task overrides (work in interactive mode per# code.claude.com/docs/en/cli-reference). ``--max-turns``,# ``--max-budget-usd``, ``--fallback-model`` are ``-p``-only anddiff --git a/server/services/cli_agent/transports/windows.py b/server/services/cli_agent/transports/windows.pyindex b584f7b7..0d99316e 100644--- a/server/services/cli_agent/transports/windows.py+++ b/server/services/cli_agent/transports/windows.py@@ -59,13 +59,25 @@ class WindowsPtyHandle:async def write(self, data: bytes) -> None:if not data:return- # pywinpty's PtyProcess.write accepts bytes; defer the actual- # WriteFile to a worker thread because ConPTY can briefly block- # under back-pressure (https://github.com/microsoft/node-pty/issues/388).+ # pywinpty v3's ``PtyProcess.write`` is str-only — the underlying+ # Rust core's ``self.pty.write(s)`` raises+ # ``TypeError: argument 'to_write': 'bytes' object cannot be cast+ # as 'str'`` on bytes. POSIX ``ptyprocess`` is bytes-native; the+ # ``PtyHandle`` Protocol picks bytes for that reason. We decode+ # at this boundary so the rest of the stack stays bytes-only.+ # Defer the actual WriteFile to a worker thread because ConPTY+ # can briefly block under back-pressure+ # (https://github.com/microsoft/node-pty/issues/388).+ try:+ text = data.decode("utf-8")+ except UnicodeDecodeError as exc:+ raise ConnectionError(+ f"PTY write failed (pid={self.pid}): non-UTF-8 payload: {exc}"+ ) from excloop = asyncio.get_running_loop()try:await loop.run_in_executor(- None, self._proc.write, data, # type: ignore[attr-defined]+ None, self._proc.write, text, # type: ignore[attr-defined])except OSError as exc:raise ConnectionError(