Skip to content

Commit 5879c9b

Browse files
authored
Merge pull request #607 from cecli-dev/v0.100.13
v0.100.13
2 parents c92e7dc + d2bd58c commit 5879c9b

5 files changed

Lines changed: 105 additions & 0 deletions

File tree

.github/workflows/ubuntu-tests.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ jobs:
5555
-r requirements/requirements-help.in \
5656
-r requirements/requirements-playwright.in \
5757
".[help,playwright]"
58+
env:
59+
PYO3_USE_ABI3_FORWARD_COMPATIBILITY: "1"
5860

5961
- name: Configure Git for tests
6062
run: |
@@ -67,3 +69,4 @@ jobs:
6769
pytest
6870
env:
6971
CECLI_TUI: "false"
72+
PYO3_USE_ABI3_FORWARD_COMPATIBILITY: "1"

.github/workflows/windows-tests.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ jobs:
4343
python -m pip install --upgrade pip
4444
pip install uv
4545
uv pip install --system pytest pytest-asyncio pytest-mock -r requirements/requirements.in -r requirements/requirements-help.in -r requirements/requirements-playwright.in '.[help,playwright]'
46+
env:
47+
PYO3_USE_ABI3_FORWARD_COMPATIBILITY: "1"
4648

4749
- name: Configure Git for tests
4850
run: |
@@ -55,3 +57,4 @@ jobs:
5557
pytest
5658
env:
5759
CECLI_TUI: "false"
60+
PYO3_USE_ABI3_FORWARD_COMPATIBILITY: "1"

cecli/commands/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from .add import AddCommand
99
from .agent import AgentCommand
1010
from .agent_model import AgentModelCommand
11+
from .agent_tree import AgentTreeCommand
1112
from .architect import ArchitectCommand
1213
from .ask import AskCommand
1314
from .clear import ClearCommand
@@ -94,6 +95,7 @@
9495
CommandRegistry.register(AddCommand)
9596
CommandRegistry.register(AgentCommand)
9697
CommandRegistry.register(AgentModelCommand)
98+
CommandRegistry.register(AgentTreeCommand)
9799
CommandRegistry.register(ArchitectCommand)
98100
CommandRegistry.register(AskCommand)
99101
CommandRegistry.register(ClearCommand)
@@ -169,6 +171,7 @@
169171
"AddCommand",
170172
"AgentCommand",
171173
"AgentModelCommand",
174+
"AgentTreeCommand",
172175
"ArchitectCommand",
173176
"AskCommand",
174177
"BaseCommand",

cecli/commands/agent_tree.py

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
from typing import List
2+
3+
from cecli.commands.utils.base_command import BaseCommand
4+
from cecli.helpers.agents.service import AgentService, SubAgentInfo, SubAgentStatus
5+
6+
7+
class TreeNode:
8+
"""A node in the agent hierarchy tree."""
9+
10+
def __init__(self, agent_info: SubAgentInfo):
11+
self.agent_info = agent_info
12+
self.children: List[TreeNode] = []
13+
14+
def add_child(self, child_node: "TreeNode"):
15+
self.children.append(child_node)
16+
17+
18+
class AgentTreeCommand(BaseCommand):
19+
"""Command to display the hierarchy of active agents."""
20+
21+
NORM_NAME = "agent-tree"
22+
DESCRIPTION = "Display the hierarchy of active agents."
23+
24+
@classmethod
25+
async def execute(cls, io, coder, args, **kwargs):
26+
"""Execute the /agent-tree command."""
27+
agent_service = AgentService.get_instance(coder)
28+
if not agent_service:
29+
io.tool_output("Agent service not available.")
30+
return
31+
32+
# Collect all agents: primary coder + sub-agents from sub_agents dict
33+
all_infos: List[SubAgentInfo] = []
34+
35+
# Primary agent as a synthetic SubAgentInfo
36+
primary_coder = agent_service.coder
37+
primary_info = SubAgentInfo(
38+
name="primary",
39+
coder=primary_coder,
40+
parent_uuid=str(primary_coder.parent_uuid or ""),
41+
status=SubAgentStatus.RUNNING,
42+
)
43+
all_infos.append(primary_info)
44+
45+
# Sub-agents from the service's sub_agents dict
46+
for info in agent_service.sub_agents.values():
47+
if info and info.coder:
48+
all_infos.append(info)
49+
50+
if len(all_infos) <= 1:
51+
io.tool_output("No active sub-agents found.")
52+
return
53+
54+
root_nodes = cls._build_tree(all_infos)
55+
tree_output = cls._render_tree(root_nodes)
56+
io.tool_output(tree_output)
57+
58+
@classmethod
59+
def _build_tree(cls, all_agents: List[SubAgentInfo]) -> List[TreeNode]:
60+
"""Build the agent tree from a flat list of agents."""
61+
nodes = {str(agent.coder.uuid): TreeNode(agent) for agent in all_agents}
62+
root_nodes = []
63+
64+
for agent in all_agents:
65+
parent_uuid = str(agent.coder.parent_uuid)
66+
if parent_uuid and parent_uuid in nodes:
67+
parent_node = nodes[parent_uuid]
68+
child_node = nodes[str(agent.coder.uuid)]
69+
parent_node.add_child(child_node)
70+
else:
71+
root_nodes.append(nodes[str(agent.coder.uuid)])
72+
73+
return root_nodes
74+
75+
@classmethod
76+
def _render_tree(cls, nodes: List[TreeNode]) -> str:
77+
"""Render the agent tree to a string."""
78+
output = []
79+
80+
def render_node(node: TreeNode, prefix: str = "", is_last: bool = True):
81+
connector = "└── " if is_last else "├── "
82+
output.append(
83+
f"{prefix}{connector}{node.agent_info.name}"
84+
f" ({node.agent_info.status.value})"
85+
f" - {str(node.agent_info.coder.uuid)}"
86+
)
87+
88+
child_prefix = prefix + (" " if is_last else "│ ")
89+
for i, child in enumerate(node.children):
90+
render_node(child, child_prefix, i == len(node.children) - 1)
91+
92+
for i, node in enumerate(nodes):
93+
render_node(node, is_last=i == len(nodes) - 1)
94+
95+
return "\n".join(output)

cecli/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1416,6 +1416,7 @@ async def send_completion(
14161416
return hash_object, self.model_error_response()
14171417

14181418
print(f"Retrying in {retry_delay:.1f} seconds...")
1419+
print(f"LiteLLM API Error: {str(err)}")
14191420
if interrupt_event:
14201421
_res, interrupted = await coroutines.interruptible(
14211422
asyncio.sleep(retry_delay), interrupt_event

0 commit comments

Comments
 (0)