fix(compression): guard overflow-warn dedup reset against minimal test doubles
The dedup-reset calls assumed a full AIAgent; gateway/loop test doubles built via object.__new__ lack _clear_context_overflow_warn and crashed in build_turn_context (caught by test_api_content_sidecar on CI slice 3). getattr-guard all four call sites per the established test-double pitfall pattern (AGENTS.md #17).
This commit is contained in:
parent
1d1b670cb5
commit
d5c03fb369
|
|
@ -1312,7 +1312,11 @@ def run_conversation(
|
|||
# blocked) — reset the blocked-overflow warning dedup so a future
|
||||
# blocked-over-threshold turn can warn again. Mirrors the
|
||||
# turn-context preflight reset (silent-overflow fix #62625).
|
||||
agent._clear_context_overflow_warn()
|
||||
# getattr guard: test doubles built via object.__new__ lack the
|
||||
# method (gateway test-double pitfall) — treat absence as no-op.
|
||||
_clear_warn = getattr(agent, "_clear_context_overflow_warn", None)
|
||||
if callable(_clear_warn):
|
||||
_clear_warn()
|
||||
logger.info(
|
||||
"Pre-API compression: ~%s request tokens >= %s threshold "
|
||||
"(context=%s, attempt=%s/%s)",
|
||||
|
|
@ -5471,7 +5475,11 @@ def run_conversation(
|
|||
# never blocked) — reset the blocked-overflow warning
|
||||
# dedup so a future blocked-over-threshold turn can warn
|
||||
# again (silent-overflow fix #62625).
|
||||
agent._clear_context_overflow_warn()
|
||||
# getattr guard: test doubles built via object.__new__ lack the
|
||||
# method (gateway test-double pitfall) — treat absence as no-op.
|
||||
_clear_warn = getattr(agent, "_clear_context_overflow_warn", None)
|
||||
if callable(_clear_warn):
|
||||
_clear_warn()
|
||||
agent._safe_print(" ⟳ compacting context…")
|
||||
messages, active_system_prompt = agent._compress_context(
|
||||
messages, system_message,
|
||||
|
|
|
|||
|
|
@ -790,7 +790,11 @@ def build_turn_context(
|
|||
# Compression is actually running (block cleared / was never
|
||||
# blocked) — reset the dedup so a future blocked-over-threshold
|
||||
# turn can warn again. Real session boundary.
|
||||
agent._clear_context_overflow_warn()
|
||||
# getattr guard: test doubles built via object.__new__ lack the
|
||||
# method (gateway test-double pitfall) — treat absence as no-op.
|
||||
_clear_warn = getattr(agent, "_clear_context_overflow_warn", None)
|
||||
if callable(_clear_warn):
|
||||
_clear_warn()
|
||||
logger.info(
|
||||
"Preflight compression: ~%s tokens >= %s threshold (model %s, ctx %s)",
|
||||
f"{_preflight_tokens:,}",
|
||||
|
|
|
|||
Loading…
Reference in New Issue