MCPcopy Create free account
hub / github.com/SkyworkAI/DeepResearchAgent / Agent

Class Agent

src/agent/types.py:227–530  ·  view source on GitHub ↗

Base class for all agents, mirroring the design of `Tool`.

Source from the content-addressed store, hash-verified

225 return self.__str__()
226
227class Agent(BaseModel):
228 """Base class for all agents, mirroring the design of `Tool`."""
229
230 model_config = ConfigDict(arbitrary_types_allowed=True, extra="allow")
231
232 name: str = Field(description="The name of the agent.")
233 description: str = Field(description="The description of the agent.")
234 metadata: Dict[str, Any] = Field(description="The metadata of the agent.")
235 version: str = Field(default="1.0.0", description="Version of the agent")
236 require_grad: bool = Field(default=False, description="Whether the agent requires gradients")
237
238 def __init__(
239 self,
240 workdir: str,
241 name: Optional[str] = None,
242 description: Optional[str] = None,
243 metadata: Optional[Dict[str, Any]] = None,
244 model_name: Optional[str] = None,
245 prompt_name: Optional[str] = None,
246 memory_name: Optional[str] = None,
247 max_tools: int = 10,
248 max_steps: int = 20,
249 review_steps: int = 5,
250 require_grad: bool = False,
251 use_memory: bool = True,
252 use_todo: bool = True,
253 **kwargs: Any,
254 ):
255 super().__init__(**kwargs)
256
257 # Set default values
258 self.name = name or self.name
259 self.description = description or self.description
260 self.metadata = metadata or self.metadata
261 self.require_grad = require_grad
262
263 # Set working directory
264 self.workdir = workdir
265
266 # Set prompt name and modules
267 self.prompt_name = prompt_name
268 self.memory_name = memory_name
269 self.use_memory = use_memory
270 self.model_name = model_name
271
272 # Setup steps
273 self.max_steps = max_steps if max_steps > 0 else int(1e8)
274 self.max_tools = max_tools
275
276 self.review_steps = review_steps
277 self.use_todo = use_todo
278
279 async def initialize(self) -> None:
280 """Initialize the agent."""
281 logger.info(f"| 📁 Agent working directory: {self.workdir}")
282
283 def __str__(self) -> str:
284 return f"Agent(name={self.name}, model={self.model_name}, prompt_name={self.prompt_name})"

Callers 1

_call_agentMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected