mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-09-04 02:01:48 +03:00
refactor(agent): remove loop iteration state (#5549)
* refactor(agent): remove loop iteration state * docs(my): remove stale iteration guidance
This commit is contained in:
@@ -57,7 +57,22 @@ def test_runtime_snapshot_has_exact_allowlist_and_redacts_secrets(tmp_path: Path
|
||||
snapshot = _my_tool(loop)._runtime_control.snapshot()
|
||||
values = snapshot.as_mapping()
|
||||
|
||||
assert frozenset(values) == RUNTIME_SNAPSHOT_KEYS
|
||||
expected_snapshot_keys = frozenset({
|
||||
"model",
|
||||
"model_preset",
|
||||
"model_presets",
|
||||
"max_iterations",
|
||||
"context_window_tokens",
|
||||
"workspace",
|
||||
"provider_retry_mode",
|
||||
"max_tool_result_chars",
|
||||
"tool_names",
|
||||
"web_config",
|
||||
"exec_config",
|
||||
"subagents",
|
||||
})
|
||||
assert RUNTIME_SNAPSHOT_KEYS == expected_snapshot_keys
|
||||
assert frozenset(values) == expected_snapshot_keys
|
||||
assert RUNTIME_COMMAND_KEYS == frozenset({
|
||||
"model",
|
||||
"model_preset",
|
||||
|
||||
@@ -32,8 +32,6 @@ def _make_mock_loop(**overrides):
|
||||
loop._start_time = 1000.0
|
||||
loop.exec_config = ExecToolConfig()
|
||||
loop.channels_config = MagicMock()
|
||||
loop._current_iteration = 0
|
||||
loop.current_iteration = loop._current_iteration
|
||||
loop.provider_retry_mode = "standard"
|
||||
loop.max_tool_result_chars = 16000
|
||||
loop.model_preset = None
|
||||
@@ -110,7 +108,6 @@ class TestInspectSummary:
|
||||
assert "workspace" in result
|
||||
assert "provider_retry_mode" in result
|
||||
assert "max_tool_result_chars" in result
|
||||
assert "_current_iteration" in result
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
@@ -1080,32 +1077,6 @@ class TestSecurityAttributeProtection:
|
||||
assert result == "model_presets.fast.model: 'fast-model'"
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# current iteration count (Fix #2)
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
class TestCurrentIteration:
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_inspect_current_iteration(self):
|
||||
tool = _make_tool()
|
||||
result = await tool.execute(action="check", key="_current_iteration")
|
||||
assert "0" in result
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_current_iteration_in_summary(self):
|
||||
tool = _make_tool()
|
||||
result = await tool.execute(action="check")
|
||||
assert "_current_iteration" in result
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_modify_current_iteration_blocked(self):
|
||||
"""_current_iteration is READ_ONLY — cannot be set manually."""
|
||||
tool = _make_tool()
|
||||
result = await tool.execute(action="set", key="_current_iteration", value=5)
|
||||
assert "read-only" in result
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# request context (audit session tracking)
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user