refactor(agent): require runtime for consolidation

This commit is contained in:
chengyongru
2026-07-10 17:54:34 +08:00
committed by Xubin Ren
parent 5bd3d1e0af
commit c9d3e74342
18 changed files with 486 additions and 214 deletions
+12 -7
View File
@@ -58,9 +58,12 @@ def test_model_preset_setter_updates_state(tmp_path) -> None:
assert loop.provider.generation.max_tokens == 4096
assert loop.provider.generation.reasoning_effort == "low"
assert not hasattr(loop.subagents, "model")
assert loop.consolidator.model == "openai/gpt-4.1"
assert loop.consolidator.context_window_tokens == 32_768
assert loop.consolidator.max_completion_tokens == 4096
assert not hasattr(loop.consolidator, "model")
assert not hasattr(loop.consolidator, "context_window_tokens")
assert loop.llm_runtime().model == "openai/gpt-4.1"
assert loop.llm_runtime().context_window_tokens == 32_768
assert not hasattr(loop.consolidator, "max_completion_tokens")
assert loop.llm_runtime().generation.max_tokens == 4096
def test_model_preset_setter_calls_runtime_model_publisher(tmp_path) -> None:
@@ -110,10 +113,11 @@ def test_model_preset_setter_replaces_provider_from_snapshot(tmp_path) -> None:
assert not hasattr(loop.runner, "provider")
assert not hasattr(loop.subagents, "provider")
assert not hasattr(loop.subagents.runner, "provider")
assert loop.consolidator.provider is new_provider
assert not hasattr(loop.consolidator, "provider")
assert loop.model == "anthropic/claude-opus-4-5"
assert loop.context_window_tokens == 200_000
assert loop.consolidator.max_completion_tokens == 2048
assert not hasattr(loop.consolidator, "max_completion_tokens")
assert loop.llm_runtime().generation.max_tokens == 2048
def test_model_preset_setter_failure_leaves_old_state(tmp_path) -> None:
@@ -136,9 +140,10 @@ def test_model_preset_setter_failure_leaves_old_state(tmp_path) -> None:
assert loop.model_preset is None
assert loop.model == "base-model"
assert not hasattr(loop.subagents, "model")
assert loop.consolidator.model == "base-model"
assert not hasattr(loop.consolidator, "model")
assert loop.context_window_tokens == 1000
assert loop.consolidator.max_completion_tokens == 123
assert not hasattr(loop.consolidator, "max_completion_tokens")
assert loop.llm_runtime().generation.max_tokens == 123
def test_active_model_preset_survives_unchanged_config_refresh(tmp_path) -> None: