Skip to content

The agent that grows with you

test: follow production methods across gateway turn extraction

Teknium04cef1e9b30b
diff --git a/tests/gateway/test_10710_auto_reset_evicts_cached_agent.py b/tests/gateway/test_10710_auto_reset_evicts_cached_agent.py
index e8a65cda89c..2c6c0d71c25 100644
--- a/tests/gateway/test_10710_auto_reset_evicts_cached_agent.py
+++ b/tests/gateway/test_10710_auto_reset_evicts_cached_agent.py
@@ -19,6 +19,7 @@ from __future__ import annotations
import ast
import inspect
+import textwrap
from gateway import run as gateway_run
from gateway import run_turn as gateway_run_turn
@@ -55,7 +56,8 @@ def test_auto_reset_cleanup_evicts_cached_agent():
conversation's cached agent (and its leaked
``context_compressor._previous_summary``) — the cache is keyed on the
stable ``session_key`` (#10710)."""
- tree = ast.parse(inspect.getsource(gateway_run_turn))
+ tree = ast.parse(textwrap.dedent(inspect.getsource(
+ gateway_run_turn.GatewayTurnMixin._hmwa_open_session)))
# Fingerprint the cleanup branch: the `if <was_auto_reset>:` block that
# clears the conversation scope via the funnel (post-#64934 refactor:
diff --git a/tests/gateway/test_35809_auto_reset_clean_context.py b/tests/gateway/test_35809_auto_reset_clean_context.py
index c75b0634080..4d3637a1436 100644
--- a/tests/gateway/test_35809_auto_reset_clean_context.py
+++ b/tests/gateway/test_35809_auto_reset_clean_context.py
@@ -35,6 +35,7 @@ from __future__ import annotations
import ast
import inspect
+import textwrap
from gateway import run as gateway_run
from gateway import run_turn as gateway_run_turn
@@ -49,7 +50,8 @@ from hermes_state import SessionDB
# ---------------------------------------------------------------------------
def _find_compression_exhausted_reset_block() -> ast.If:
"""Return the ``if agent_result.get('compression_exhausted') ...`` block."""
- tree = ast.parse(inspect.getsource(gateway_run_turn))
+ tree = ast.parse(textwrap.dedent(inspect.getsource(
+ gateway_run_turn.GatewayTurnMixin._hmwa_compression_exhaustion_reset)))
for node in ast.walk(tree):
if not isinstance(node, ast.If):
diff --git a/tests/gateway/test_48031_model_switch_after_auto_reset.py b/tests/gateway/test_48031_model_switch_after_auto_reset.py
index 9cbdb70e4ab..c54bcfdc885 100644
--- a/tests/gateway/test_48031_model_switch_after_auto_reset.py
+++ b/tests/gateway/test_48031_model_switch_after_auto_reset.py
@@ -22,6 +22,7 @@ from __future__ import annotations
import ast
import inspect
+import textwrap
from gateway import run_turn as gateway_run_turn
from gateway import slash_commands_model as gateway_slash
@@ -47,7 +48,8 @@ def test_run_consumes_was_auto_reset_in_cleanup_block():
`session_entry.was_auto_reset = False` so the cleanup (which pops the
session model/reasoning overrides) cannot re-fire on the next message and
wipe an override stored between turns (#48031)."""
- tree = ast.parse(inspect.getsource(gateway_run_turn))
+ tree = ast.parse(textwrap.dedent(inspect.getsource(
+ gateway_run_turn.GatewayTurnMixin._hmwa_open_session)))
# Find the cleanup branch: an `if <flag>:` block that clears the
# conversation scope (post-funnel: one _clear_conversation_scope call
diff --git a/tests/gateway/test_compression_deferred_soft_result.py b/tests/gateway/test_compression_deferred_soft_result.py
index 24284f74a74..780e615e48d 100644
--- a/tests/gateway/test_compression_deferred_soft_result.py
+++ b/tests/gateway/test_compression_deferred_soft_result.py
@@ -20,6 +20,7 @@ from __future__ import annotations
import ast
import inspect
+import textwrap
from gateway import run as gateway_run
from gateway import run_turn as gateway_run_turn
@@ -37,7 +38,8 @@ def _calls(node: ast.AST) -> set[str]:
def _find_deferred_guarded_reset_chain() -> ast.If:
"""Return the ``if agent_result.get('compression_deferred') ... elif
agent_result.get('compression_exhausted') ... reset_session`` chain."""
- tree = ast.parse(inspect.getsource(gateway_run_turn))
+ tree = ast.parse(textwrap.dedent(inspect.getsource(
+ gateway_run_turn.GatewayTurnMixin._hmwa_compression_exhaustion_reset)))
for node in ast.walk(tree):
if not isinstance(node, ast.If):