55from collections .abc import Generator , Iterable
66from typing import TYPE_CHECKING , Any
77
8- from pydantic import BaseModel , ConfigDict , Field , PrivateAttr , model_validator
8+ from pydantic import BaseModel , ConfigDict , Field , PrivateAttr
99
1010from openhands .sdk .context .agent_context import AgentContext
1111from openhands .sdk .context .condenser import CondenserBase , LLMSummarizingCondenser
1212from openhands .sdk .context .prompts .prompt import render_template
1313from openhands .sdk .llm import LLM
1414from openhands .sdk .logger import get_logger
1515from openhands .sdk .mcp import create_mcp_tools
16- from openhands .sdk .security import analyzer
1716from openhands .sdk .tool import BUILT_IN_TOOLS , Tool , ToolDefinition , resolve_tool
18- from openhands .sdk .utils .deprecation import (
19- warn_deprecated ,
20- )
2117from openhands .sdk .utils .models import DiscriminatedUnionMixin
2218from openhands .sdk .utils .pydantic_diff import pretty_pydantic_diff
2319
3026logger = get_logger (__name__ )
3127
3228
33- AGENT_SECURITY_ANALYZER_DEPRECATION_DETAILS = (
34- "Use `conversation = Conversation(); "
35- "conversation.set_security_analyzer(...)` instead."
36- )
37-
38-
3929class AgentBase (DiscriminatedUnionMixin , ABC ):
4030 """Abstract base class for OpenHands agents.
4131
@@ -132,12 +122,6 @@ class AgentBase(DiscriminatedUnionMixin, ABC):
132122 examples = [{"cli_mode" : True }],
133123 )
134124
135- security_analyzer : analyzer .SecurityAnalyzerBase | None = Field (
136- default = None ,
137- description = "Optional security analyzer to evaluate action risks." ,
138- examples = [{"kind" : "LLMSecurityAnalyzer" }],
139- )
140-
141125 condenser : CondenserBase | None = Field (
142126 default = None ,
143127 description = "Optional condenser to use for condensing conversation history." ,
@@ -158,24 +142,6 @@ class AgentBase(DiscriminatedUnionMixin, ABC):
158142 # Runtime materialized tools; private and non-serializable
159143 _tools : dict [str , ToolDefinition ] = PrivateAttr (default_factory = dict )
160144
161- @model_validator (mode = "before" )
162- @classmethod
163- def _coerce_inputs (cls , data ):
164- if not isinstance (data , dict ):
165- return data
166- d = dict (data )
167-
168- if "security_analyzer" in d and d ["security_analyzer" ]:
169- warn_deprecated (
170- "Agent.security_analyzer" ,
171- deprecated_in = "1.1.0" ,
172- removed_in = "1.3.0" ,
173- details = AGENT_SECURITY_ANALYZER_DEPRECATION_DETAILS ,
174- stacklevel = 3 ,
175- )
176-
177- return d
178-
179145 @property
180146 def prompt_dir (self ) -> str :
181147 """Returns the directory where this class's module file is located."""
@@ -222,15 +188,6 @@ def init_state(
222188 def _initialize (self , state : "ConversationState" ):
223189 """Create an AgentBase instance from an AgentSpec."""
224190
225- # 1) Migrate deprecated analyzer → state (if present)
226- if self .security_analyzer and not state .security_analyzer :
227- state .security_analyzer = self .security_analyzer
228- # 2) Clear on the immutable model (allowed via object.__setattr__)
229- try :
230- object .__setattr__ (self , "security_analyzer" , None )
231- except Exception :
232- logger .warning ("Could not clear deprecated Agent.security_analyzer" )
233-
234191 if self ._tools :
235192 logger .warning ("Agent already initialized; skipping re-initialization." )
236193 return
@@ -299,8 +256,7 @@ def step(
299256 def resolve_diff_from_deserialized (self , persisted : "AgentBase" ) -> "AgentBase" :
300257 """
301258 Return a new AgentBase instance equivalent to `persisted` but with
302- explicitly whitelisted fields (e.g. api_key, security_analyzer) taken from
303- `self`.
259+ explicitly whitelisted fields (e.g. api_key) taken from `self`.
304260 """
305261 if persisted .__class__ is not self .__class__ :
306262 raise ValueError (
@@ -329,9 +285,6 @@ def resolve_diff_from_deserialized(self, persisted: "AgentBase") -> "AgentBase":
329285 )
330286 updates ["condenser" ] = new_condenser
331287
332- # Allow security_analyzer to differ - use the runtime (self) version
333- updates ["security_analyzer" ] = self .security_analyzer
334-
335288 # Create maps by tool name for easy lookup
336289 runtime_tools_map = {tool .name : tool for tool in self .tools }
337290 persisted_tools_map = {tool .name : tool for tool in persisted .tools }
0 commit comments