diff --git a/agents/s01_agent_loop.py b/agents/s01_agent_loop.py index 3e6c9133d..f89be1f68 100644 --- a/agents/s01_agent_loop.py +++ b/agents/s01_agent_loop.py @@ -26,6 +26,11 @@ import os import subprocess +try: + import readline +except Exception: + readline = None + from anthropic import Anthropic from dotenv import load_dotenv diff --git a/agents/s02_tool_use.py b/agents/s02_tool_use.py index a05ac4bf9..a042df277 100644 --- a/agents/s02_tool_use.py +++ b/agents/s02_tool_use.py @@ -22,6 +22,11 @@ import subprocess from pathlib import Path +try: + import readline +except Exception: + readline = None + from anthropic import Anthropic from dotenv import load_dotenv diff --git a/agents/s03_todo_write.py b/agents/s03_todo_write.py index 9ca805c05..79a980bd4 100644 --- a/agents/s03_todo_write.py +++ b/agents/s03_todo_write.py @@ -30,6 +30,11 @@ import subprocess from pathlib import Path +try: + import readline +except Exception: + readline = None + from anthropic import Anthropic from dotenv import load_dotenv diff --git a/agents/s04_subagent.py b/agents/s04_subagent.py index 9de087b1f..a65717413 100644 --- a/agents/s04_subagent.py +++ b/agents/s04_subagent.py @@ -26,6 +26,11 @@ import subprocess from pathlib import Path +try: + import readline +except Exception: + readline = None + from anthropic import Anthropic from dotenv import load_dotenv diff --git a/agents/s05_skill_loading.py b/agents/s05_skill_loading.py index ee8ffc157..44d5e8b46 100644 --- a/agents/s05_skill_loading.py +++ b/agents/s05_skill_loading.py @@ -39,6 +39,11 @@ import subprocess from pathlib import Path +try: + import readline +except Exception: + readline = None + from anthropic import Anthropic from dotenv import load_dotenv diff --git a/agents/s06_context_compact.py b/agents/s06_context_compact.py index b9c6aa8d2..62e7a6cb9 100644 --- a/agents/s06_context_compact.py +++ b/agents/s06_context_compact.py @@ -39,6 +39,11 @@ import time from pathlib import Path +try: + import readline +except Exception: + readline = None + from anthropic import Anthropic from dotenv import load_dotenv @@ -196,6 +201,7 @@ def agent_loop(messages: list): # Layer 1: micro_compact before each LLM call micro_compact(messages) # Layer 2: auto_compact if token estimate exceeds threshold + print(f"\033[33m$ Input tokens: {estimate_tokens(messages)}\033[0m") if estimate_tokens(messages) > THRESHOLD: print("[auto_compact triggered]") messages[:] = auto_compact(messages) @@ -211,6 +217,7 @@ def agent_loop(messages: list): for block in response.content: if block.type == "tool_use": if block.name == "compact": + print(f"\033[33m$ Compact: {block.input['focus']}\033[0m") manual_compact = True output = "Compressing..." else: diff --git a/agents/s07_task_system.py b/agents/s07_task_system.py index 82b16af62..d41a6cc8e 100644 --- a/agents/s07_task_system.py +++ b/agents/s07_task_system.py @@ -26,6 +26,11 @@ import subprocess from pathlib import Path +try: + import readline +except Exception: + readline = None + from anthropic import Anthropic from dotenv import load_dotenv diff --git a/agents/s08_background_tasks.py b/agents/s08_background_tasks.py index 77a992eaf..2a641afd8 100644 --- a/agents/s08_background_tasks.py +++ b/agents/s08_background_tasks.py @@ -30,6 +30,11 @@ import uuid from pathlib import Path +try: + import readline +except Exception: + readline = None + from anthropic import Anthropic from dotenv import load_dotenv diff --git a/agents/s09_agent_teams.py b/agents/s09_agent_teams.py index 284a1ac19..d71210440 100644 --- a/agents/s09_agent_teams.py +++ b/agents/s09_agent_teams.py @@ -49,6 +49,11 @@ import time from pathlib import Path +try: + import readline +except Exception: + readline = None + from anthropic import Anthropic from dotenv import load_dotenv diff --git a/agents/s10_team_protocols.py b/agents/s10_team_protocols.py index 21f936df3..ce3d3992e 100644 --- a/agents/s10_team_protocols.py +++ b/agents/s10_team_protocols.py @@ -54,6 +54,11 @@ import uuid from pathlib import Path +try: + import readline +except Exception: + readline = None + from anthropic import Anthropic from dotenv import load_dotenv diff --git a/agents/s11_autonomous_agents.py b/agents/s11_autonomous_agents.py index 856bc92c3..cfb30e452 100644 --- a/agents/s11_autonomous_agents.py +++ b/agents/s11_autonomous_agents.py @@ -42,6 +42,11 @@ import uuid from pathlib import Path +try: + import readline +except Exception: + readline = None + from anthropic import Anthropic from dotenv import load_dotenv diff --git a/agents/s12_worktree_task_isolation.py b/agents/s12_worktree_task_isolation.py index 0162de58f..743770f62 100644 --- a/agents/s12_worktree_task_isolation.py +++ b/agents/s12_worktree_task_isolation.py @@ -36,6 +36,11 @@ import time from pathlib import Path +try: + import readline +except Exception: + readline = None + from anthropic import Anthropic from dotenv import load_dotenv diff --git a/agents/s_full.py b/agents/s_full.py index d4dcfd3c6..26b7becd5 100644 --- a/agents/s_full.py +++ b/agents/s_full.py @@ -45,6 +45,11 @@ from pathlib import Path from queue import Queue +try: + import readline +except Exception: + readline = None + from anthropic import Anthropic from dotenv import load_dotenv