Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions agents/s01_agent_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
import os
import subprocess

try:
import readline
except Exception:
readline = None

from anthropic import Anthropic
from dotenv import load_dotenv

Expand Down
5 changes: 5 additions & 0 deletions agents/s02_tool_use.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions agents/s03_todo_write.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions agents/s04_subagent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions agents/s05_skill_loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 7 additions & 0 deletions agents/s06_context_compact.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand All @@ -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:
Expand Down
5 changes: 5 additions & 0 deletions agents/s07_task_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions agents/s08_background_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions agents/s09_agent_teams.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions agents/s10_team_protocols.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions agents/s11_autonomous_agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions agents/s12_worktree_task_isolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions agents/s_full.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down