Skip to content

Fix private attribute access, zip length validation, test isolation, and monkeypatch module path#128

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/fix-private-attribute-access
Draft

Fix private attribute access, zip length validation, test isolation, and monkeypatch module path#128
Copilot wants to merge 3 commits intomainfrom
copilot/fix-private-attribute-access

Conversation

Copy link
Contributor

Copilot AI commented Mar 18, 2026

Seven targeted code-quality fixes across encapsulation violations, silent failure modes, and test hygiene issues.

Encapsulation (streaming_context.py)

  • Replace direct agent._max_depth and agent._current_effective_max_iters accesses with getattr chains that prefer public properties and fall back to private attributes gracefully.

Silent mismatch (runner_callbacks.py)

  • Replace zip(strict=False) with an explicit pre-check that raises a descriptive ValueError when run_semantic_tasks_batched returns a different number of results than inputs.
if len(values) != len(task_specs):
    raise ValueError(
        "Batch LLM query length mismatch in llm_query_batched: expected "
        f"{len(task_specs)} results but got {len(values)}"
    )

Test fixes (test_daytona_rlm_smoke.py)

  • Rename counterstate_value in _FakeSession to distinguish it clearly from execute_calls.
  • Fix monkeypatch.setattr target from the stale fleet_rlm.daytona_rlm.smoke path to the correct fleet_rlm.infrastructure.providers.daytona.smoke.DaytonaSandboxRuntime.

Test isolation (test_ws_chat_helpers.py)

  • Remove cross-suite import from tests.ui.fixtures_ui import ts; replace with a local ts identity helper to eliminate the unit↔UI fixture dependency.
  • Add a docstring to module-level _noop_persist clarifying its role.
Original prompt
Please apply the following diffs and create a pull request.
Once the PR is ready, give it a title based on the messages of the fixes being applied.

[{"message":"Accessing private attribute `_max_depth` directly violates encapsulation. Consider adding a public property or method on the agent class to expose this value.","fixFiles":[{"filePath":"src/fleet_rlm/core/execution/streaming_context.py","diff":"diff --git a/src/fleet_rlm/core/execution/streaming_context.py b/src/fleet_rlm/core/execution/streaming_context.py\n--- a/src/fleet_rlm/core/execution/streaming_context.py\n+++ b/src/fleet_rlm/core/execution/streaming_context.py\n@@ -69,7 +69,7 @@\n \n         return cls(\n             depth=agent.current_depth,\n-            max_depth=agent._max_depth,\n+            max_depth=getattr(agent, \"max_depth\", getattr(agent, \"_max_depth\")),\n             execution_profile=profile_name,\n             volume_name=getattr(interpreter, \"volume_name\", None),\n             sandbox_active=getattr(interpreter, \"_sandbox\", None) is not None,\n"}]},{"message":"Accessing private attribute `_current_effective_max_iters` directly violates encapsulation. Consider adding a public property or method on the agent class to expose this value.","fixFiles":[{"filePath":"src/fleet_rlm/core/execution/streaming_context.py","diff":"diff --git a/src/fleet_rlm/core/execution/streaming_context.py b/src/fleet_rlm/core/execution/streaming_context.py\n--- a/src/fleet_rlm/core/execution/streaming_context.py\n+++ b/src/fleet_rlm/core/execution/streaming_context.py\n@@ -76,7 +76,11 @@\n             effective_max_iters=(\n                 effective_max_iters\n                 if effective_max_iters is not None\n-                else agent._current_effective_max_iters\n+                else (\n+                    getattr(agent, \"current_effective_max_iters\", None)\n+                    or getattr(agent, \"_current_effective_max_iters\", None)\n+                    or cls().effective_max_iters\n+                )\n             ),\n             execution_mode=str(getattr(agent, \"execution_mode\", \"auto\") or \"auto\"),\n             sandbox_id=None,\n"}]},{"message":"The `zip` with `strict=False` could silently ignore mismatches between `task_specs` and `values` lengths. If `run_semantic_tasks_batched` returns fewer or more results than expected, the mismatch won't be caught. Set `strict=True` to ensure both lists have the same length, or add explicit length validation.","fixFiles":[{"filePath":"src/fleet_rlm/daytona_rlm/runner_callbacks.py","diff":"diff --git a/src/fleet_rlm/daytona_rlm/runner_callbacks.py b/src/fleet_rlm/daytona_rlm/runner_callbacks.py\n--- a/src/fleet_rlm/daytona_rlm/runner_callbacks.py\n+++ b/src/fleet_rlm/daytona_rlm/runner_callbacks.py\n@@ -154,7 +154,12 @@\n             return []\n \n         values = self._runner.run_semantic_tasks_batched(task_specs=task_specs)\n-        for task_spec, value in zip(task_specs, values, strict=False):\n+        if len(values) != len(task_specs):\n+            raise ValueError(\n+                \"llm_query_batched: expected \"\n+                f\"{len(task_specs)} results but got {len(values)}\"\n+            )\n+        for task_spec, value in zip(task_specs, values):\n             node.child_links.append(\n                 ChildLink(\n                     child_id=None,\n"}]},{"message":"The variables 'counter' and 'execute_calls' serve similar purposes (tracking state across execute_code calls). Consider renaming 'counter' to something more descriptive like 'state_value' or 'persisted_value' to clarify its distinct purpose in validating driver persistence.","fixFiles":[{"filePath":"tests/unit/test_daytona_rlm_smoke.py","diff":"diff --git a/tests/unit/test_daytona_rlm_smoke.py b/tests/unit/test_daytona_rlm_smoke.py\n--- a/tests/unit/test_daytona_rlm_smoke.py\n+++ b/tests/unit/test_daytona_rlm_smoke.py\n@@ -19,7 +19,7 @@\n         self.phase_timings_ms = {\"sandbox_create\": 2, \"repo_clone\": 4}\n         self.driver_started = False\n         self.deleted = False\n-        self.counter = 0\n+        self.state_value = 0\n         self.execute_calls = 0\n         self.prompt_counter = 0\n         self.prompt_store: dict[str, str] = {}\n@@ -34,7 +34,7 @@\n         del code, callback_handler, timeout, submit_schema\n         self.execute_calls += 1\n         if self.execute_calls == 1:\n-            self.counter = 2\n+            self.state_value = 2\n             return type(\n                 \"_ExecResponse\",\n                 (),\n@@ -48,7 +48,7 @@\n                 },\n             )()\n \n-        self.counter += 3\n+        self.state_value += 3\n         return type(\n             \"_ExecResponse\",\n             (),\n@@ -58,7 +58,7 @@\n                 \"error\": None,\n                 \"final_artifact\": {\n                     \"kind\": \"markdown\",\n-                    \"value\": {\"output\": self.counter},\n+                    \"value\": {\"output\"...

📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.

…olation, and module path issues

Co-authored-by: Zochory <60674042+Zochory@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix direct access to private attribute _max_depth Fix private attribute access, zip length validation, test isolation, and monkeypatch module path Mar 18, 2026
Copilot AI requested a review from Zochory March 18, 2026 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants