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:
1 parent
3bf4a6f63c
commit
6b1c461a80
4 files changed
+104
-12
No files matched your search
@@ -10,8 +10,8 @@ from __future__ import annotations
|
||||
|
||||
from langchain_core.messages import HumanMessage, SystemMessage
|
||||
|
||||
COMPACT_RATIO = 0.9 # compact once the prompt reaches this fraction of the context window
|
||||
KEEP_LAST = 20 # verbatim recent turns to retain after compaction
|
||||
COMPACT_RATIO = 0.9 # compact once the prompt reaches this fraction of the token budget
|
||||
KEEP_LAST = 12 # verbatim recent turns to retain after compaction (keeps post-compaction small)
|
||||
_CHARS_PER_TOKEN = 4 # rough fallback when the server doesn't report token counts
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user