Skip to content

Commit eae91c3

Browse files
committed
Add Agent Type Attribute
1 parent b0fb5cc commit eae91c3

File tree

7 files changed

+12
-5
lines changed

7 files changed

+12
-5
lines changed

bindings/ceylon/ceylon/agent/agent.py

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55

66
class Agent(Worker, AgentCommon):
7+
agent_type = "AGENT"
78
history_responses = []
89

910
def __init__(self, name="admin",

bindings/ceylon/ceylon/core/worker.py

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111

1212
class Worker(WorkerAgent, Processor, MessageHandler, EventHandler):
13+
agent_type = "WORKER"
1314

1415
def __init__(self, name="admin", workspace_id=DEFAULT_WORKSPACE_ID, admin_peer="", admin_port=DEFAULT_ADMIN_PORT,
1516
role="worker",

bindings/ceylon/ceylon/llm/llm_task_coordinator.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import pydantic.v1
44
from langchain_core.output_parsers import StrOutputParser
55
from langchain_core.prompts import ChatPromptTemplate, PromptTemplate
6+
from loguru import logger
67

78
from ceylon.llm.llm_task_operator import LLMTaskOperator
89
from ceylon.static_val import DEFAULT_WORKSPACE_ID, DEFAULT_ADMIN_PORT
@@ -43,6 +44,7 @@ def __init__(self, tasks: List[Task], agents: List[LLMTaskOperator], llm=None, t
4344
self.tool_llm = tool_llm
4445
self.tasks = tasks
4546
self.agents = agents
47+
logger.info(f"LLM Task Coordinator initialized with {len(tasks)} tasks and {len(self.get_llm_operators)} agents {[agent for agent in self.get_llm_operators]}")
4648
super().__init__(name=name, port=port, tasks=tasks, agents=agents)
4749

4850
async def get_task_executor(self, task: SubTask) -> str:
@@ -68,7 +70,8 @@ async def update_task(self, idx: int, task: Task):
6870
def get_llm_operators(self) -> List[LLMTaskOperator]:
6971
operators = []
7072
for agent in self.agents:
71-
if isinstance(agent, LLMTaskOperator):
73+
if isinstance(agent, LLMTaskOperator) and hasattr(agent,
74+
"agent_type") and agent.agent_type == LLMTaskOperator.agent_type:
7275
operators.append(agent)
7376

7477
return operators

bindings/ceylon/ceylon/llm/llm_task_operator.py

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313

1414

1515
class LLMTaskOperator(TaskOperator):
16+
"""LLM-based task operator."""
17+
agent_type = "LLM_TASK_OPERATOR"
18+
1619
def __init__(self, name: str, role: str, context: str, skills: List[str],
1720
tools: List[Any] = None, llm=None, tool_llm=None, verbose=False,
1821
workspace_id="ceylon_agent_stack",

bindings/ceylon/ceylon/task/task_operation.py

-3
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@ class Task(BaseModel):
4141

4242
def add_subtask(self, subtask: SubTask):
4343
subtask.parent_task_id = self.id
44-
if subtask.name in self.subtasks:
45-
raise ValueError(f"Subtask with id {subtask.name} already exists")
46-
4744
self.subtasks[subtask.name] = subtask
4845
self._validate_dependencies()
4946
self.execution_order = self.get_execution_order()

bindings/ceylon/ceylon/task/task_operator.py

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111

1212
class TaskOperator(Agent, abc.ABC):
13+
agent_type = "TASK_OPERATOR"
14+
1315
def __init__(self, name: str, role: str, workspace_id: str = DEFAULT_WORKSPACE_ID,
1416
admin_port: int = DEFAULT_ADMIN_PORT, *args,
1517
**kwargs):

bindings/ceylon/tests/tasks/llm_software_agency.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
),
5353
AgentMonitor()
5454
]
55-
# enable_log("DEBUG")
55+
# enable_log("INFO")
5656
# Initialize TaskManager
5757
task_manager = LLMTaskCoordinator(tasks, agents, tool_llm=tool_llm, llm=llm)
5858

0 commit comments

Comments
 (0)