fix: address PR review — alias expansion + L3 budget enforcement

- Add `shopt -s expand_aliases` to snapshot so aliases captured by
  `alias -p` actually work under `bash -c` (review comment #2)
- Pass threshold=0 in enforce_turn_budget() so L3 can force-persist
  results below the 50K default when aggregate budget is exceeded
  (review comment #3)
- Add regression test: 6x42K results (each under 50K) exceeding 200K
  budget are now correctly persisted
This commit is contained in:
alt-glitch
2026-04-03 01:03:02 +05:30
committed by Hermes Agent
parent 72bd14e09d
commit 51cf4e0bbc
3 changed files with 54 additions and 24 deletions

View File

@@ -28,7 +28,6 @@ logger = logging.getLogger(__name__)
DEFAULT_MAX_RESULT_SIZE_CHARS: int = 50_000
MAX_TURN_BUDGET_CHARS: int = 200_000
PREVIEW_SIZE_CHARS: int = 2000
PREVIEW_SIZE_BYTES = PREVIEW_SIZE_CHARS # deprecated alias
PERSISTED_OUTPUT_TAG = "<persisted-output>"
PERSISTED_OUTPUT_CLOSING_TAG = "</persisted-output>"
@@ -179,7 +178,8 @@ def enforce_turn_budget(
content = msg["content"]
tool_use_id = msg.get("tool_call_id", f"budget_{idx}")
result = persist_large_result(content, tool_use_id, storage_dir)
result = persist_large_result(content, tool_use_id, storage_dir,
threshold=0)
if result:
replacement = build_persisted_output_message(result)
total_size -= size