Skip to content

fix(tests): resolve test failures across framework and tools#7059

Merged
Hundao merged 3 commits into
aden-hive:mainfrom
Hundao:fix/test-failures
Apr 16, 2026
Merged

fix(tests): resolve test failures across framework and tools#7059
Hundao merged 3 commits into
aden-hive:mainfrom
Hundao:fix/test-failures

Conversation

@Hundao

@Hundao Hundao commented Apr 16, 2026

Copy link
Copy Markdown
Collaborator

Description

Fix 103 test failures (52 framework + 52 tools + flaky colony fork) to restore CI test checks on main. Depends on #7058 (lint fix).

Type of Change

  • Bug fix (non-breaking change that fixes an issue)

Related Issues

Partial fix for #7057

Changes Made

Framework tests (52 -> 1 failure):

  • Add missing model attribute to 11 mock LLM classes to match new agent_loop.py:624 requirement
  • Update skill count assertions from 6 to 7 (new writing-hive-skills skill)
  • Fix phase compaction test to match new message format (no square brackets)
  • Update model catalog test for current gemini model names (2.5 -> 3.1)
  • Fix queen memory test: set phase="building" to match prompt_building, adjust reflection trigger count

Tools tests (52 -> 0 failures):

  • Update csv_tool tests: remove agent_id parameter, use absolute paths, patch _ALLOWED_ROOTS instead of AGENT_SANDBOXES_DIR
  • Fix browser_evaluate test to allow toast wrapper around script

Remaining: 1 pre-existing failure in test_worker_report_emits_subagent_report_event where mock LLM gets stuck when scenarios are exhausted (separate bug, not a test assertion issue).

Testing

  • Framework tests: 1563 passed, 15 skipped
  • Tools tests: 6609 passed, 0 failed, 294 skipped
  • Lint passes

Summary by CodeRabbit

  • New Features

    • Expanded framework default skills from six to seven.
  • Bug Fixes

    • Updated model catalog expectations for MiniMax and Gemini models.
    • Refined pruned tool-result message handling to avoid double-pruning.
    • Cleaner worker shutdown/duplicate-task behavior: ensures a final "Done." stop is emitted.
  • Chores

    • Adjusted default skill token budget constraints.
    • Improved CSV tool tests to work with updated sandbox path rules.
  • Tests

    • Standardized test mocks to expose a consistent model identifier.

@coderabbitai

coderabbitai Bot commented Apr 16, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Added model: str = "mock" to many test-local/mock LLM classes; adjusted multiple test expectations (default skills 6→7, token budget, model-catalog entries, pruned-message prefixes, memory housekeeping counts); refactored CSV tests to use tmp_path and patched _ALLOWED_ROOTS; removed import-time hive path rebinding.

Changes

Cohort / File(s) Summary
Mock LLM Provider Attribute Additions
core/tests/test_colony_runtime_overseer.py, core/tests/test_context_handoff.py, core/tests/test_event_loop_node.py, core/tests/test_litellm_provider.py, core/tests/test_llm_judge.py, core/tests/test_run_parallel_workers_tool.py
Added model: str = "mock" to many test-local/mock LLM classes; some mocks also track _used_tasks and early-exit with a final TextDeltaEvent("Done.") + FinishEvent when scenarios are reused or exhausted. No core logic changes outside tests.
Default Skills & CLI
core/tests/test_default_skills.py, core/tests/test_skill_cli_commands.py
Updated expectations from 6→7 default skills, increased combined token budget threshold (<3000), and refined placeholder-check logic by removing one known literal before asserting no unreplaced placeholders.
Model Catalog & Related Tests
core/tests/test_model_catalog.py, core/tests/test_llm_judge.py
Removed two MiniMax highspeed IDs from expected list; changed a gemini model lookup and updated expected max_context_tokens; added model attr to MockLLMProvider in judge tests.
Pruning / Compaction / Conversation
core/framework/agent_loop/conversation.py, core/framework/agent_loop/internals/compaction.py, core/tests/test_phase_compaction.py
Broadened pruned-placeholder matching to accept both "[Pruned tool result" and "Pruned tool result" prefixes; microcompact skip-condition expanded to match additional legacy prefixes; updated related test assertions accordingly.
Queen Memory / Phase Tests
core/tests/test_queen_memory.py
Adjusted expected await counts for unified housekeeping calls and made QueenPhaseState phase explicit in one test.
Colony Runtime Overseer / Crash Tests
core/tests/test_colony_runtime_overseer.py
Mock streaming LLM now yields a final "Done." text + FinishEvent on exhausted/reused scenarios; CrashingLLM also exposes model: str = "mock". Crash semantics otherwise unchanged.
Colony Fork Live Simplification
core/tests/test_colony_fork_live.py
Removed import-time hive path rebinding and related constants; simplified isolated_hive_home fixture to rely on conftest autouse isolation and use expanded-user config path.
Browser Tools Assertion Relaxation
tools/tests/test_browser_tools_comprehensive.py
Loosened bridge.evaluate assertion to accept multiple call args and assert at least one contains "return 42;", preserving expected bridge return value.
CSV Tool Tests Refactor
tools/tests/tools/test_csv_tool.py
Large refactor: removed TEST_AGENT_ID/session_dir fixture, write fixtures directly under tmp_path, pass absolute path strings, patch _ALLOWED_ROOTS instead of AGENT_SANDBOXES_DIR, and update assertions/paths accordingly (many lines changed).

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

🐇 Seven hops across the test-green floor,
Mock models whisper, "run once more."
CSVs nestle in tmp_path beds,
Pruned messages wear both old and new threads.
The warren cheers — tests sleeker than before.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 74.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix(tests): resolve test failures across framework and tools' accurately summarizes the primary change: a comprehensive test failure resolution effort across multiple test suites affecting the framework and tools modules.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Framework tests (52 -> 1 failure):
- Add missing `model` attribute to mock LLM classes (MockStreamingLLM,
  CrashingLLM, ErrorThenSuccessLLM, etc.) to match new agent_loop.py
  requirement at line 624
- Update skill count assertions from 6 to 7 (new writing-hive-skills)
- Fix phase compaction test to match new message format (no brackets)
- Update model catalog test for current gemini model names
- Fix queen memory test: set phase="building" to match prompt_building,
  adjust reflection trigger count to match cooldown behavior

Tools tests (52 -> 0 failures):
- Update csv_tool tests: remove agent_id parameter, use absolute paths,
  patch _ALLOWED_ROOTS instead of AGENT_SANDBOXES_DIR
- Fix browser_evaluate test to allow toast wrapper around script

Remaining: 1 pre-existing failure in test_worker_report where mock LLM
gets stuck when scenarios are exhausted (separate bug).
@Hundao
Hundao force-pushed the fix/test-failures branch from bcce254 to 0f40a59 Compare April 16, 2026 11:40

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (3)
tools/tests/tools/test_csv_tool.py (2)

1-11: Missing from __future__ import annotations import.

Per coding guidelines, this import should be added for modern type syntax.

 """Tests for csv_tool - Read and manipulate CSV files."""

+from __future__ import annotations
+
 import importlib.util
 from pathlib import Path
 from unittest.mock import patch
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tools/tests/tools/test_csv_tool.py` around lines 1 - 11, Add the missing
"from __future__ import annotations" at the top of the test module to comply
with the project's typing guidelines; open the test file that contains import
statements (the one importing importlib.util, Path, patch, pytest, FastMCP and
register_tools) and place this future import as the first non-comment line so
modern type annotations are enabled for the module.

15-29: Redundant patching of _ALLOWED_ROOTS throughout tests.

The csv_tools fixture already patches _ALLOWED_ROOTS with the yield inside the with block (lines 18-29), meaning the patch remains active during test execution. Each test method then redundantly patches the same value again.

Since all tests use either csv_tools or csv_tool_fn (which depends on csv_tools), and both share the same function-scoped tmp_path, the per-test patches are unnecessary.

Consider removing the redundant with patch(...) blocks from individual test methods to reduce duplication. For example, test_read_basic_csv could simplify to:

def test_read_basic_csv(self, csv_tool_fn, basic_csv, tmp_path):
    """Read a basic CSV file successfully."""
    result = csv_tool_fn(path=str(basic_csv))

    assert result["success"] is True
    # ... rest of assertions

This pattern repeats across all test methods in this file (~40 occurrences).

Also applies to: 79-93

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tools/tests/tools/test_csv_tool.py` around lines 15 - 29, The tests
redundantly patch aden_tools.tools.file_system_toolkits.security._ALLOWED_ROOTS
inside individual test functions even though the csv_tools fixture already
patches it; remove the per-test with patch(...) blocks from tests that accept
csv_tools or csv_tool_fn and rely on tmp_path, and simplify those tests (e.g.,
test_read_basic_csv) to call the tool function directly (csv_tool_fn(...))
without re-patching; ensure csv_tools (which calls register_tools(mcp) and sets
_ALLOWED_ROOTS) remains function-scoped so tmp_path isolation is preserved and
no other changes to register_tools, csv_tools, csv_tool_fn, or FastMCP behavior
are needed.
core/tests/test_llm_judge.py (1)

26-27: Align mock provider model with returned LLMResponse.model.

MockLLMProvider.model is now "mock" while complete() returns "mock-model". Keeping these consistent reduces test ambiguity.

Suggested tweak
-    model: str = "mock"
+    model: str = "mock-model"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@core/tests/test_llm_judge.py` around lines 26 - 27, The test sets
MockLLMProvider.model = "mock" but MockLLMProvider.complete() returns an
LLMResponse with model "mock-model", causing inconsistency; update either
MockLLMProvider.model or the returned LLMResponse.model in complete() so they
match (e.g., change MockLLMProvider.model to "mock-model" or return
LLMResponse.model = self.model) — locate MockLLMProvider and its complete()
method and make the string values consistent.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@core/tests/test_default_skills.py`:
- Line 22: The test function test_all_seven_skills_exist is missing a return
type annotation; update its signature to include an explicit return type (e.g.,
add "-> None") so the function follows the project's type-hinting guideline for
all function signatures.
- Around line 242-244: Only remove the single example placeholder so real
leftover placeholders aren't masked: assert that prompt.count("{{placeholder}}")
>= 1, then call prompt.replace("{{placeholder}}", "", 1) to remove just one
occurrence into cleaned, and keep the existing assert "{{" not in cleaned to
catch any other unremoved placeholders; reference the prompt variable, cleaned
variable, and the replace(...) call.

In `@core/tests/test_phase_compaction.py`:
- Line 215: The test asserts old_tool[0].content.startswith("Pruned tool
result") but compaction.py's detection still only checks for the prefix "[Pruned
tool result", causing a mismatch; update the compaction detection logic in
core/framework/agent_loop/internals/compaction.py (the function/logic that
checks for the pruned-tool sentinel, e.g., the is-pruned or PRUNED_TOOL_*
matching code) to accept the test prefix by matching either "Pruned tool result"
or both variants (e.g., .startswith(("Pruned tool result", "[Pruned tool
result"))), so production detection and the tests are aligned.

---

Nitpick comments:
In `@core/tests/test_llm_judge.py`:
- Around line 26-27: The test sets MockLLMProvider.model = "mock" but
MockLLMProvider.complete() returns an LLMResponse with model "mock-model",
causing inconsistency; update either MockLLMProvider.model or the returned
LLMResponse.model in complete() so they match (e.g., change
MockLLMProvider.model to "mock-model" or return LLMResponse.model = self.model)
— locate MockLLMProvider and its complete() method and make the string values
consistent.

In `@tools/tests/tools/test_csv_tool.py`:
- Around line 1-11: Add the missing "from __future__ import annotations" at the
top of the test module to comply with the project's typing guidelines; open the
test file that contains import statements (the one importing importlib.util,
Path, patch, pytest, FastMCP and register_tools) and place this future import as
the first non-comment line so modern type annotations are enabled for the
module.
- Around line 15-29: The tests redundantly patch
aden_tools.tools.file_system_toolkits.security._ALLOWED_ROOTS inside individual
test functions even though the csv_tools fixture already patches it; remove the
per-test with patch(...) blocks from tests that accept csv_tools or csv_tool_fn
and rely on tmp_path, and simplify those tests (e.g., test_read_basic_csv) to
call the tool function directly (csv_tool_fn(...)) without re-patching; ensure
csv_tools (which calls register_tools(mcp) and sets _ALLOWED_ROOTS) remains
function-scoped so tmp_path isolation is preserved and no other changes to
register_tools, csv_tools, csv_tool_fn, or FastMCP behavior are needed.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f0bd3047-f300-4ea2-9352-db77266c191c

📥 Commits

Reviewing files that changed from the base of the PR and between 589c5b0 and 0f40a59.

📒 Files selected for processing (13)
  • core/tests/test_colony_runtime_overseer.py
  • core/tests/test_context_handoff.py
  • core/tests/test_default_skills.py
  • core/tests/test_event_loop_node.py
  • core/tests/test_litellm_provider.py
  • core/tests/test_llm_judge.py
  • core/tests/test_model_catalog.py
  • core/tests/test_phase_compaction.py
  • core/tests/test_queen_memory.py
  • core/tests/test_run_parallel_workers_tool.py
  • core/tests/test_skill_cli_commands.py
  • tools/tests/test_browser_tools_comprehensive.py
  • tools/tests/tools/test_csv_tool.py


def test_all_six_skills_exist(self):
assert len(SKILL_REGISTRY) == 6
def test_all_seven_skills_exist(self):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Add return type hint to the renamed test method.

Line 22 introduces a changed function signature without an explicit type hint.

Suggested fix
-    def test_all_seven_skills_exist(self):
+    def test_all_seven_skills_exist(self) -> None:

As per coding guidelines, "Use type hints on all function signatures".

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
def test_all_seven_skills_exist(self):
def test_all_seven_skills_exist(self) -> None:
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@core/tests/test_default_skills.py` at line 22, The test function
test_all_seven_skills_exist is missing a return type annotation; update its
signature to include an explicit return type (e.g., add "-> None") so the
function follows the project's type-hinting guideline for all function
signatures.

Comment on lines +242 to +244
# Remove the known literal {{placeholder}} documentation example
cleaned = prompt.replace("{{placeholder}}", "")
assert "{{" not in cleaned

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Current placeholder cleanup can mask real regressions.

replace("{{placeholder}}", "") removes all occurrences, so multiple unintended placeholders could slip through undetected.

Suggested fix
-        # Remove the known literal {{placeholder}} documentation example
-        cleaned = prompt.replace("{{placeholder}}", "")
+        # Remove exactly one known literal {{placeholder}} documentation example
+        literal_placeholder = "{{placeholder}}"
+        assert prompt.count(literal_placeholder) == 1
+        cleaned = prompt.replace(literal_placeholder, "", 1)
         assert "{{" not in cleaned
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@core/tests/test_default_skills.py` around lines 242 - 244, Only remove the
single example placeholder so real leftover placeholders aren't masked: assert
that prompt.count("{{placeholder}}") >= 1, then call
prompt.replace("{{placeholder}}", "", 1) to remove just one occurrence into
cleaned, and keep the existing assert "{{" not in cleaned to catch any other
unremoved placeholders; reference the prompt variable, cleaned variable, and the
replace(...) call.

Comment thread core/tests/test_phase_compaction.py
- Add text stop scenario to test_worker_report so worker terminates
  cleanly after tool_calls finish instead of replaying the last
  scenario forever
- Remove duplicated hive home isolation fixture from test_colony_fork_live;
  reuse conftest autouse fixture and only add config copy on top

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@core/tests/test_colony_fork_live.py`:
- Around line 60-75: Add Python type hints to the fixture: annotate the
parameter _isolate_hive_home_autouse as Path and the return as Iterator[Path]
(or Generator[Path, None, None]) so the signature becomes e.g. def
isolated_hive_home(_isolate_hive_home_autouse: Path) -> Iterator[Path]: and add
the needed import from typing (Iterator) at the top of the file; keep the body
unchanged and ensure Path is the same pathlib.Path used elsewhere.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 68a3c2ec-db8a-4659-8e04-d843cf488102

📥 Commits

Reviewing files that changed from the base of the PR and between 0f40a59 and 7340eb6.

📒 Files selected for processing (2)
  • core/tests/test_colony_fork_live.py
  • core/tests/test_colony_runtime_overseer.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • core/tests/test_colony_runtime_overseer.py

Comment on lines +60 to 75
def isolated_hive_home(_isolate_hive_home_autouse):
"""Extend the conftest autouse fixture with the user's LLM configuration.

Copies the user's real ~/.hive/configuration.json into the temp home
so the LLM provider config (model, api_base) is preserved.
The conftest ``_isolate_hive_home_autouse`` fixture already redirects
``~/.hive`` to a temp directory and patches all module-level path
constants. This fixture just copies the real ``configuration.json``
so the live integration test can pick up API keys and model config.
"""
fake_home_root = tmp_path
fake_hive = fake_home_root / ".hive"
fake_hive.mkdir()
fake_hive = _isolate_hive_home_autouse

# Copy LLM configuration so the framework picks up the user's model.
# Done BEFORE we monkey-patch Path.home so the source resolves correctly.
real_config = Path.home() / ".hive" / "configuration.json"
# Use os.path.expanduser since Path.home() is already patched by conftest.
real_config = Path(os.path.expanduser("~/.hive/configuration.json"))
if real_config.exists():
shutil.copy(real_config, fake_hive / "configuration.json")

# Patch Path.home -> tmp_path so any call-site computation goes there.
monkeypatch.setattr(Path, "home", classmethod(lambda cls: fake_home_root))

# Patch every module-level binding that captured a path constant.
for mod_name in _HIVE_PATH_CONSUMERS:
try:
mod = importlib.import_module(mod_name)
except ImportError:
continue
for attr_name, builder in _HIVE_PATH_NAMES:
if hasattr(mod, attr_name):
monkeypatch.setattr(mod, attr_name, builder(fake_hive))

yield fake_hive

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
python - <<'PY'
import ast
from pathlib import Path

path = Path("core/tests/test_colony_fork_live.py")
tree = ast.parse(path.read_text(encoding="utf-8"))

for node in tree.body:
    if isinstance(node, ast.FunctionDef) and node.name == "isolated_hive_home":
        missing_args = [a.arg for a in node.args.args if a.annotation is None]
        print("function:", node.name)
        print("missing_arg_annotations:", missing_args)
        print("missing_return_annotation:", node.returns is None)
PY

Repository: aden-hive/hive

Length of output: 174


🏁 Script executed:

# Find and examine the _isolate_hive_home_autouse fixture definition
fd -t f 'conftest.py' -x grep -l '_isolate_hive_home_autouse' {}

Repository: aden-hive/hive

Length of output: 82


🏁 Script executed:

# Examine the conftest.py file to find the fixture definition
cat -n ./core/tests/conftest.py | grep -A 20 '_isolate_hive_home_autouse'

Repository: aden-hive/hive

Length of output: 1177


🏁 Script executed:

# Get more context to see what the fixture returns/yields
cat -n ./core/tests/conftest.py | sed -n '63,95p'

Repository: aden-hive/hive

Length of output: 1204


🏁 Script executed:

# Check the actual function and its current imports at the top of the file
cat -n ./core/tests/test_colony_fork_live.py | head -80

Repository: aden-hive/hive

Length of output: 3128


Add type hints to the fixture signature.

Line 60 defines isolated_hive_home without parameter and return annotations, violating the repository's Python typing requirement.

♻️ Proposed fix
 import asyncio
+from collections.abc import Iterator
 import json
 import os
 import shutil
 import time
 from pathlib import Path
@@
 `@pytest.fixture`
-def isolated_hive_home(_isolate_hive_home_autouse):
+def isolated_hive_home(_isolate_hive_home_autouse: Path) -> Iterator[Path]:
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@core/tests/test_colony_fork_live.py` around lines 60 - 75, Add Python type
hints to the fixture: annotate the parameter _isolate_hive_home_autouse as Path
and the return as Iterator[Path] (or Generator[Path, None, None]) so the
signature becomes e.g. def isolated_hive_home(_isolate_hive_home_autouse: Path)
-> Iterator[Path]: and add the needed import from typing (Iterator) at the top
of the file; keep the body unchanged and ensure Path is the same pathlib.Path
used elsewhere.

fix(core): accept both pruned tool result sentinel formats

MockStreamingLLM and _ByTaskMockLLM replay the last scenario forever
when call_index exceeds the scenario list, causing worker timeouts in
CI. Fix by emitting a text stop when scenarios are exhausted (scenarios
mode) or already consumed (by_task mode).

Also fix pruned tool result sentinel mismatch: conversation.py produces
"Pruned tool result ..." but compaction.py and conversation.py only
checked for "[Pruned tool result". Now both formats are accepted.

Also remove duplicated hive home isolation fixture from
test_colony_fork_live; reuse conftest autouse fixture instead.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@core/framework/agent_loop/internals/compaction.py`:
- Line 83: In microcompact(), the startswith check for tool-result placeholders
misses the unbracketed "Old tool result" variant so those placeholders get
re-compacted; update the conditional in microcompact() (the tuple passed to
msg.content.startswith) to include "Old tool result" in addition to "[Old tool
result", "[Pruned tool result", and "Pruned tool result" so both bracketed and
non-bracketed placeholder strings are recognized and skipped.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: be7b291e-2585-40af-acc6-81731f746f09

📥 Commits

Reviewing files that changed from the base of the PR and between 7340eb6 and f3e0cd0.

📒 Files selected for processing (4)
  • core/framework/agent_loop/conversation.py
  • core/framework/agent_loop/internals/compaction.py
  • core/tests/test_colony_runtime_overseer.py
  • core/tests/test_run_parallel_workers_tool.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • core/tests/test_run_parallel_workers_tool.py
  • core/tests/test_colony_runtime_overseer.py

if msg.role != "tool" or msg.is_error or msg.is_skill_content:
continue
if msg.content.startswith(("[Pruned tool result", "[Old tool result")):
if msg.content.startswith(("Pruned tool result", "[Pruned tool result", "[Old tool result")):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Handle bracketless "Old tool result" placeholders too.

On Line 83, microcompact() skips "[Old tool result" but not "Old tool result" (the format this file currently writes). That allows already-cleared spillover placeholders to be compacted again.

Suggested fix
-        if msg.content.startswith(("Pruned tool result", "[Pruned tool result", "[Old tool result")):
+        if msg.content.startswith(
+            ("Pruned tool result", "[Pruned tool result", "Old tool result", "[Old tool result")
+        ):
             continue
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@core/framework/agent_loop/internals/compaction.py` at line 83, In
microcompact(), the startswith check for tool-result placeholders misses the
unbracketed "Old tool result" variant so those placeholders get re-compacted;
update the conditional in microcompact() (the tuple passed to
msg.content.startswith) to include "Old tool result" in addition to "[Old tool
result", "[Pruned tool result", and "Pruned tool result" so both bracketed and
non-bracketed placeholder strings are recognized and skipped.

@Hundao
Hundao merged commit e5a93b0 into aden-hive:main Apr 16, 2026
8 of 10 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Apr 25, 2026
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.

1 participant