mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-15 14:22:43 +00:00
fix(codex): reject interrupted manual compaction
This commit is contained in:
parent
8c62a92296
commit
8121dbb166
3 changed files with 33 additions and 15 deletions
|
|
@ -1074,7 +1074,7 @@ def _compress_context_via_codex_app_server(
|
|||
pass
|
||||
agent._codex_session = None
|
||||
|
||||
if getattr(result, "error", None):
|
||||
if getattr(result, "interrupted", False) or getattr(result, "error", None):
|
||||
try:
|
||||
agent._emit_warning(
|
||||
f"⚠ Codex app-server compaction failed: {result.error}"
|
||||
|
|
|
|||
|
|
@ -755,22 +755,22 @@ class CodexAppServerSession:
|
|||
turn_obj = (note.get("params") or {}).get("turn") or {}
|
||||
result.turn_id = turn_obj.get("id") or result.turn_id
|
||||
turn_status = turn_obj.get("status")
|
||||
if turn_status and turn_status not in {"completed", "interrupted"}:
|
||||
if turn_status == "interrupted":
|
||||
result.interrupted = True
|
||||
result.error = result.error or "compact turn interrupted"
|
||||
elif turn_status and turn_status != "completed":
|
||||
err_obj = turn_obj.get("error")
|
||||
if err_obj:
|
||||
err_msg = _format_responses_error(err_obj, str(turn_status))
|
||||
stderr_blob = "\n".join(
|
||||
self._client.stderr_tail(40)
|
||||
err_msg = _format_responses_error(err_obj, str(turn_status))
|
||||
stderr_blob = "\n".join(self._client.stderr_tail(40))
|
||||
hint = _classify_oauth_failure(err_msg, stderr_blob)
|
||||
if hint is not None:
|
||||
result.error = hint
|
||||
result.should_retire = True
|
||||
else:
|
||||
result.error = self._format_error_with_stderr(
|
||||
f"compact turn ended status={turn_status}",
|
||||
err_msg,
|
||||
)
|
||||
hint = _classify_oauth_failure(err_msg, stderr_blob)
|
||||
if hint is not None:
|
||||
result.error = hint
|
||||
result.should_retire = True
|
||||
else:
|
||||
result.error = self._format_error_with_stderr(
|
||||
f"compact turn ended status={turn_status}",
|
||||
err_msg,
|
||||
)
|
||||
|
||||
if not turn_complete and not result.interrupted:
|
||||
self._issue_interrupt(result.turn_id)
|
||||
|
|
|
|||
|
|
@ -528,6 +528,24 @@ class TestCompactThread:
|
|||
assert r.token_usage_last["totalTokens"] == 12
|
||||
assert r.model_context_window == 200000
|
||||
|
||||
def test_compact_thread_interrupted_returns_non_success(self):
|
||||
client = FakeClient()
|
||||
client.queue_notification(
|
||||
"turn/started",
|
||||
threadId="thread-fake-001",
|
||||
turn={"id": "compact-turn-1"},
|
||||
)
|
||||
client.queue_notification(
|
||||
"turn/completed",
|
||||
threadId="thread-fake-001",
|
||||
turn={"id": "compact-turn-1", "status": "interrupted", "error": None},
|
||||
)
|
||||
|
||||
result = make_session(client).compact_thread(turn_timeout=2.0)
|
||||
|
||||
assert result.interrupted is True
|
||||
assert result.error == "compact turn interrupted"
|
||||
|
||||
def test_compact_thread_failure_returns_error(self):
|
||||
client = FakeClient()
|
||||
from agent.transports.codex_app_server import CodexAppServerError
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue