[claude] Split thinking.py into focused sub-modules (#1279) (#1306)
Some checks failed
Tests / lint (push) Has been cancelled
Tests / test (push) Has been cancelled

This commit was merged in pull request #1306.
This commit is contained in:
2026-03-24 01:57:04 +00:00
parent de7744916c
commit e44db42c1a
10 changed files with 1509 additions and 1392 deletions

View File

@@ -334,7 +334,7 @@ async def test_think_once_disabled(tmp_path):
"""think_once should return None when thinking is disabled."""
engine = _make_engine(tmp_path)
with patch("timmy.thinking.settings") as mock_settings:
with patch("timmy.thinking.engine.settings") as mock_settings:
mock_settings.thinking_enabled = False
thought = await engine.think_once()
@@ -381,7 +381,7 @@ async def test_think_once_prompt_includes_memory_context(tmp_path):
return "A grounded thought."
with (
patch("timmy.thinking.HOT_MEMORY_PATH", memory_md),
patch("timmy.thinking._snapshot.HOT_MEMORY_PATH", memory_md),
patch.object(engine, "_call_agent", side_effect=capture_agent),
patch.object(engine, "_log_event"),
patch.object(engine, "_update_memory"),
@@ -412,7 +412,7 @@ async def test_think_once_prompt_includes_soul(tmp_path):
return "A soulful thought."
with (
patch("timmy.thinking.SOUL_PATH", soul_md),
patch("timmy.thinking._snapshot.SOUL_PATH", soul_md),
patch.object(engine, "_call_agent", side_effect=capture_agent),
patch.object(engine, "_log_event"),
patch.object(engine, "_update_memory"),
@@ -433,7 +433,7 @@ async def test_think_once_graceful_without_soul(tmp_path):
nonexistent = tmp_path / "no_such_soul.md"
with (
patch("timmy.thinking.SOUL_PATH", nonexistent),
patch("timmy.thinking._snapshot.SOUL_PATH", nonexistent),
patch.object(engine, "_call_agent", return_value="Still thinking."),
patch.object(engine, "_log_event"),
patch.object(engine, "_update_memory"),
@@ -481,7 +481,7 @@ async def test_think_once_never_writes_soul(tmp_path):
soul_md.write_text(original_content)
with (
patch("timmy.thinking.SOUL_PATH", soul_md),
patch("timmy.thinking._snapshot.SOUL_PATH", soul_md),
patch.object(engine, "_call_agent", return_value="A deep reflection."),
patch.object(engine, "_log_event"),
patch.object(engine, "_broadcast", new_callable=AsyncMock),
@@ -501,7 +501,7 @@ async def test_think_once_memory_update_graceful_on_failure(tmp_path):
# Don't create the parent dir — write will fail
with (
patch("timmy.thinking.HOT_MEMORY_PATH", bad_memory),
patch("timmy.thinking._snapshot.HOT_MEMORY_PATH", bad_memory),
patch.object(engine, "_call_agent", return_value="Resilient thought."),
patch.object(engine, "_log_event"),
patch.object(engine, "_broadcast", new_callable=AsyncMock),
@@ -1090,7 +1090,7 @@ def test_maybe_check_memory_fires_at_interval(tmp_path):
engine._store_thought(f"Thought {i}.", "freeform")
with (
patch("timmy.thinking.settings") as mock_settings,
patch("timmy.thinking._distillation.settings") as mock_settings,
patch(
"timmy.tools_intro.get_memory_status",
return_value={
@@ -1113,7 +1113,7 @@ def test_maybe_check_memory_skips_between_intervals(tmp_path):
engine._store_thought(f"Thought {i}.", "freeform")
with (
patch("timmy.thinking.settings") as mock_settings,
patch("timmy.thinking._distillation.settings") as mock_settings,
patch(
"timmy.tools_intro.get_memory_status",
) as mock_status,
@@ -1131,7 +1131,7 @@ def test_maybe_check_memory_graceful_on_error(tmp_path):
engine._store_thought(f"Thought {i}.", "freeform")
with (
patch("timmy.thinking.settings") as mock_settings,
patch("timmy.thinking._distillation.settings") as mock_settings,
patch(
"timmy.tools_intro.get_memory_status",
side_effect=Exception("boom"),