The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
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.pyindex 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 annotationsimport astimport inspect+import textwrapfrom gateway import run as gateway_runfrom 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 thestable ``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.pyindex 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 annotationsimport astimport inspect+import textwrapfrom gateway import run as gateway_runfrom 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.pyindex 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 annotationsimport astimport inspect+import textwrapfrom gateway import run_turn as gateway_run_turnfrom 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 thesession model/reasoning overrides) cannot re-fire on the next message andwipe 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 calldiff --git a/tests/gateway/test_compression_deferred_soft_result.py b/tests/gateway/test_compression_deferred_soft_result.pyindex 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 annotationsimport astimport inspect+import textwrapfrom gateway import run as gateway_runfrom 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') ... elifagent_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):