@@ -1095,7 +1095,10 @@ async def fake_run_guardrails(**kwargs: Any) -> list[GuardrailResult]:
10951095 # Verify the context has the get_conversation_history method
10961096 assert hasattr (captured_context , "get_conversation_history" ) # noqa: S101
10971097
1098- # Verify conversation history is present
1098+ # Verify conversation_history is accessible as an attribute (per GuardrailLLMContextProto)
1099+ assert hasattr (captured_context , "conversation_history" ) # noqa: S101
1100+
1101+ # Verify conversation history is present via method
10991102 conversation_history = captured_context .get_conversation_history ()
11001103 assert len (conversation_history ) == 3 # noqa: S101
11011104 assert conversation_history [0 ]["role" ] == "user" # noqa: S101
@@ -1104,6 +1107,9 @@ async def fake_run_guardrails(**kwargs: Any) -> list[GuardrailResult]:
11041107 assert conversation_history [2 ]["role" ] == "user" # noqa: S101
11051108 assert conversation_history [2 ]["content" ] == "Thanks!" # noqa: S101
11061109
1110+ # Verify conversation history is also accessible via direct attribute access
1111+ assert captured_context .conversation_history == conversation_history # noqa: S101
1112+
11071113
11081114@pytest .mark .asyncio
11091115async def test_agent_guardrail_with_empty_conversation_history (monkeypatch : pytest .MonkeyPatch ) -> None :
@@ -1142,10 +1148,16 @@ async def fake_run_guardrails(**kwargs: Any) -> list[GuardrailResult]:
11421148 # Verify the context has the get_conversation_history method
11431149 assert hasattr (captured_context , "get_conversation_history" ) # noqa: S101
11441150
1145- # Verify conversation history is empty but accessible
1151+ # Verify conversation_history is accessible as an attribute (per GuardrailLLMContextProto)
1152+ assert hasattr (captured_context , "conversation_history" ) # noqa: S101
1153+
1154+ # Verify conversation history is empty but accessible via method
11461155 conversation_history = captured_context .get_conversation_history ()
11471156 assert conversation_history == [] # noqa: S101
11481157
1158+ # Verify conversation history is also accessible via direct attribute access
1159+ assert captured_context .conversation_history == [] # noqa: S101
1160+
11491161
11501162# =============================================================================
11511163# Tests for updated tool-level guardrail behavior (stage_name)
0 commit comments