mirror of https://github.com/kortix-ai/suna.git
Add update method to Agent class for modifying agent properties
- Implemented an `update` method in the `Agent` class to allow modification of agent properties such as name, system prompt, and associated tools. - Enhanced tool management by configuring `AgentPressTools` and `MCPTools` for the update process. - Updated the `create` method in `KortixAgent` to maintain consistency with the new method signature.
This commit is contained in:
parent
4ca74e9907
commit
2302b656f0
|
@ -4,6 +4,7 @@ from .tools import AgentPressTools, MCPTools, KortixTools
|
||||||
from .api.agents import (
|
from .api.agents import (
|
||||||
AgentCreateRequest,
|
AgentCreateRequest,
|
||||||
AgentPress_ToolConfig,
|
AgentPress_ToolConfig,
|
||||||
|
AgentUpdateRequest,
|
||||||
AgentsClient,
|
AgentsClient,
|
||||||
CustomMCP,
|
CustomMCP,
|
||||||
MCPConfig,
|
MCPConfig,
|
||||||
|
@ -15,6 +16,39 @@ class Agent:
|
||||||
self._client = client
|
self._client = client
|
||||||
self._agent_id = agent_id
|
self._agent_id = agent_id
|
||||||
|
|
||||||
|
async def update(
|
||||||
|
self,
|
||||||
|
name: str,
|
||||||
|
system_prompt: str,
|
||||||
|
mcp_tools: list[KortixTools] = [],
|
||||||
|
):
|
||||||
|
agentpress_tools = {}
|
||||||
|
custom_mcps: list[CustomMCP] = []
|
||||||
|
for tool in mcp_tools:
|
||||||
|
if isinstance(tool, AgentPressTools):
|
||||||
|
agentpress_tools[tool] = AgentPress_ToolConfig(
|
||||||
|
enabled=True, description=tool.get_description()
|
||||||
|
)
|
||||||
|
elif isinstance(tool, MCPTools):
|
||||||
|
mcp = tool
|
||||||
|
custom_mcps.append(
|
||||||
|
CustomMCP(
|
||||||
|
name=mcp.name,
|
||||||
|
type=mcp.type,
|
||||||
|
config=MCPConfig(url=mcp.url),
|
||||||
|
enabled_tools=mcp.enabled_tools,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
await self._client.update_agent(
|
||||||
|
self._agent_id,
|
||||||
|
AgentUpdateRequest(
|
||||||
|
name=name,
|
||||||
|
system_prompt=system_prompt,
|
||||||
|
custom_mcps=custom_mcps,
|
||||||
|
agentpress_tools=agentpress_tools,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
async def run(
|
async def run(
|
||||||
self,
|
self,
|
||||||
prompt: str,
|
prompt: str,
|
||||||
|
@ -37,7 +71,11 @@ class KortixAgent:
|
||||||
self._client = client
|
self._client = client
|
||||||
|
|
||||||
async def create(
|
async def create(
|
||||||
self, name: str, system_prompt: str, model: str, mcp_tools: list[KortixTools] = []
|
self,
|
||||||
|
name: str,
|
||||||
|
system_prompt: str,
|
||||||
|
model: str,
|
||||||
|
mcp_tools: list[KortixTools] = [],
|
||||||
) -> Agent:
|
) -> Agent:
|
||||||
agentpress_tools = {}
|
agentpress_tools = {}
|
||||||
custom_mcps: list[CustomMCP] = []
|
custom_mcps: list[CustomMCP] = []
|
||||||
|
|
Loading…
Reference in New Issue