fix(agents): survive long overnight runs

- compact at memory-safe token budget (~20k) not the 131k window; gpt-oss
  hits oMLX's prefill memory guard ~47k tokens on a 24GB machine
- repair invalid_tool_calls (malformed JSON args) before echoing history —
  LangChain serializes the raw malformed string which oMLX 500s on
- retry invokes (4x) with an oMLX watchdog restart between attempts
- ALWAYS finalize: salvage picks from findings even after invoke failures

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016DvdRZkyCy9NJpHYDdPqmS
This commit is contained in:
Aryan SinghandClaude Opus 4.8 committed 2026-07-02 12:22:29 -05:00
1 parent 3bf4a6f63c
commit 6b1c461a80
4 files changed
+104 -12

No files matched your search

+4
View File
@@ -56,6 +56,10 @@ class Settings(BaseSettings):
per_agent_min_steps: int = 25 # secondary floor (steps)
hard_stop: str = "07:00" # local wall-clock HH:MM; nightly run must finish by this
sandbox_timeout_s: int = 90 # run_analysis script wall-clock limit
# Compact when the prompt approaches this many tokens. This is the MEMORY-safe KV ceiling
# for a 24GB Mac (gpt-oss hits oMLX's prefill guard ~47k tokens / ~16GB) — NOT the model's
# 131k context window. Keeping context well under the guard is what makes long runs survive.
compaction_token_budget: int = 26000
# --- Email (daily report; use a Gmail App Password, never your real password) ---
email_to: str = ""