Self-improving AI Employees for everyone
Python ai-agentsai-employeeai-employeesassistantautonomous-agentsco-employeescompanygrok-botinstinctloop-agentsmuseown-your-datapersonalself-hosted
fix(teams): show a teammate's tools and skills on the lead's roster
trohitg637aea0b7dc2
diff --git a/docs-internal/agent_teams.md b/docs-internal/agent_teams.mdindex 046f5c00..29f414f6 100644--- a/docs-internal/agent_teams.md+++ b/docs-internal/agent_teams.md@@ -8,8 +8,22 @@ leads cannot receive team tasks.## Runtime model1. `build_teammate_descriptors()` expands connected agents into stable- identities containing node ID, type, label, capability description,- provider/model configuration, and the child's connected tools and skills.+ identities (node ID, type, label, `delegate_tool_name`).+ `collect_teammate_connections()` enriches each with the teammate's+ parameters, `child_tools` (its `input-tools` edges), `child_skills` (its+ `input-skill` edges, Master Skill nodes expanded to their enabled+ entries) and a rendered `capabilities` sentence:+ `tools: TikHub (Scrape TikTok, Douyin, ...); skills: tikhub-skill (...)`.+ Tool blurbs come from the plugin's `description` ClassVar, skill blurbs+ from the SKILL.md frontmatter description; the runtime `skill` entry and+ `*-personality` skills are skipped. `format_teammate_roster_line()` turns+ that into the one line per teammate both runtimes put in the lead's+ system prompt (`- <node_id>: <label> (<type>) - <capabilities>`). This+ roster is the lead's ONLY view of what a teammate can do, because the+ `delegate_to_*` tools that carry the long capability description are+ hidden from the lead's model (point 4), so a teammate labelled "Web+ Agent" holding TikHub would otherwise be indistinguishable from one+ holding nothing. Locked by `tests/test_team_topology.py`.2. Task Manager is intrinsically and non-removably bound to every team lead.It is not a palette node or an Agent Builder-addable tool.3. The lead delegates only by calling `task_manager` withdiff --git a/docs-internal/tikhub_service.md b/docs-internal/tikhub_service.mdindex e86df8a8..63101044 100644--- a/docs-internal/tikhub_service.md+++ b/docs-internal/tikhub_service.md@@ -269,6 +269,21 @@ dormant - the manual tracker does the work, because the framework'scost hook fires per operation and cannot know whether the call wasbilled.+## Team visibility++A team lead (`orchestrator_agent` / `ai_employee`) never sees a teammate's+tools directly: the `delegate_to_*` tool that carries `tool_description` is+hidden from the lead's model. What the lead sees is the roster line+`collect_teammate_connections()` renders per teammate+(`services/plugin/edge_walker.py::format_teammate_roster_line`), which+lists the teammate's connected tools by the plugin `description` ClassVar+and its Master Skill entries by SKILL.md description. So when `tikhubAction`+hangs off a subagent, the lead's prompt reads+`- web_1: Web Agent (aiAgent) - tools: TikHub (Scrape TikTok, Douyin, ...); skills: tikhub-skill (...)`.+Keep `TikHubActionNode.description` and the skill's frontmatter+`description` written as capability sentences for that reason. See+[agent_teams.md](./agent_teams.md).+## SDK version-bump recipe1. Edit the pin in `server/pyproject.toml` (`"tikhub>=2.1.2,<3"` - keepdiff --git a/server/nodes/agent/_inline.py b/server/nodes/agent/_inline.pyindex d1df34fb..5ed4d768 100644--- a/server/nodes/agent/_inline.py+++ b/server/nodes/agent/_inline.py@@ -105,6 +105,8 @@ async def prepare_agent_call("label": tm["label"],"parameters": tm.get("parameters", {}),"child_tools": tm.get("child_tools", []),+ "child_skills": tm.get("child_skills", []),+ "capabilities": tm.get("capabilities", ""),"delegate_tool_name": tm["delegate_tool_name"],})diff --git a/server/services/ai.py b/server/services/ai.pyindex 8c007a69..dbd63bed 100644--- a/server/services/ai.py+++ b/server/services/ai.py@@ -1655,10 +1655,9 @@ class AIService:task_manager_bound = any(info.get("node_type") == "taskManager" for info in effective_tool_data)durable_delegates = [info for info in effective_tool_data if info.get("delegate_tool_name")]if task_manager_bound and durable_delegates:- teammate_lines = "\n".join(- f"- {info.get('node_id')}: {info.get('label') or info.get('node_type')} ({info.get('node_type')})"- for info in durable_delegates- )+ from services.plugin.edge_walker import format_teammate_roster_line++ teammate_lines = "\n".join(format_teammate_roster_line(info) for info in durable_delegates)system_message += ("\n\n## Durable Team Delegation\n""All teammate assignments MUST use task_manager with operation='assign_task'. "diff --git a/server/services/plugin/edge_walker.py b/server/services/plugin/edge_walker.pyindex 3d19615a..21f39c85 100644--- a/server/services/plugin/edge_walker.py+++ b/server/services/plugin/edge_walker.py@@ -550,6 +550,129 @@ def extract_task_event_payload(value: Any) -> Optional[Dict[str, Any]]:return None+# Cap on each tool / skill blurb inside a teammate's capability summary.+# The summary rides the lead's system prompt once per teammate, so it must+# stay a roster line, not a manual: full instructions live on the teammate.+_CAPABILITY_BLURB_CHARS = 160+# Master-Skill entries that describe the agent runtime rather than a domain+# capability. They are enabled on every Master Skill node and would only add+# noise to a roster.+_ROSTER_SKIPPED_SKILLS = frozenset({"skill"})+++def _clip(text: str, limit: int = _CAPABILITY_BLURB_CHARS) -> str:+ text = " ".join(str(text or "").split())+ return text if len(text) <= limit else text[: limit - 3].rstrip() + "..."+++def _tool_blurb(node_type: str) -> str:+ """One-line, human-facing capability text for a tool node type.++ Prefers the plugin's ``description`` ClassVar (a sentence written for+ people) over ``tool_description`` (an instruction block written for the+ model that holds the tool) so a lead's roster stays readable.+ """+ from services.node_registry import get_node_class++ cls = get_node_class(node_type)+ if cls is None:+ return ""+ return _clip(+ (getattr(cls, "description", "") or "").strip()+ or (getattr(cls, "tool_description", "") or "").strip()+ )+++async def _teammate_child_skills(+ teammate_id: str,+ nodes: List[Dict[str, Any]],+ edges: List[Dict[str, Any]],+ database: "Database",+) -> List[Dict[str, Any]]:+ """Skills wired to a teammate's ``input-skill`` handle, with descriptions.++ Master Skill nodes expand to their enabled entries; the description is+ the SKILL.md frontmatter text (or the per-node override), the same value+ the teammate's own ``Skill`` catalogue shows. Personality and runtime+ skills are skipped: they shape how the agent behaves, not what it can+ do for the lead.+ """+ skills: List[Dict[str, Any]] = []+ registry = None+ for edge in edges:+ if edge.get("target") != teammate_id or edge_target_handle(edge) != "input-skill":+ continue+ child = next((n for n in nodes if n.get("id") == edge.get("source")), None)+ if not child:+ continue+ params = await database.get_node_parameters(child.get("id")) or {}+ if child.get("type") == "masterSkill":+ skills_config = params.get("skills_config") or {}+ if not isinstance(skills_config, dict):+ continue+ for skill_key, skill_cfg in skills_config.items():+ if not isinstance(skill_cfg, dict) or not skill_cfg.get("enabled", False):+ continue+ if skill_key in _ROSTER_SKIPPED_SKILLS or skill_key.endswith("-personality"):+ continue+ if registry is None:+ from services.skill_loader import get_skill_loader++ try:+ registry = get_skill_loader().scan_skills()+ except Exception as exc: # noqa: BLE001 - a roster must never fail a run+ logger.warning("[Teams] skill registry unavailable for roster: %s", exc)+ registry = {}+ meta = registry.get(skill_key)+ description = skill_cfg.get("description") or (meta.description if meta else "")+ skills.append({"node_id": child.get("id"), "skill_name": skill_key, "description": _clip(description)})+ else:+ skill_name = params.get("skill_name") or (child.get("data") or {}).get("label") or child.get("type")+ skills.append({"node_id": child.get("id"), "skill_name": str(skill_name), "description": ""})+ return skills+++def describe_teammate_capabilities(+ child_tools: List[Dict[str, Any]],+ child_skills: List[Dict[str, Any]],+) -> str:+ """Render a teammate's connected tools and skills as one roster sentence.++ ``"tools: TikHub (Scrape TikTok, Douyin, ...); skills: tikhub-skill+ (...)"``. Empty when the teammate has neither, so callers can omit the+ clause entirely.+ """+ parts: List[str] = []+ tool_bits = []+ for tool in child_tools:+ label = str(tool.get("label") or tool.get("node_type") or "")+ blurb = _tool_blurb(str(tool.get("node_type") or ""))+ tool_bits.append(f"{label} ({blurb})" if blurb else label)+ if tool_bits:+ parts.append("tools: " + ", ".join(tool_bits))+ skill_bits = []+ for skill in child_skills:+ name = str(skill.get("skill_name") or "")+ blurb = str(skill.get("description") or "")+ skill_bits.append(f"{name} ({blurb})" if blurb else name)+ if skill_bits:+ parts.append("skills: " + ", ".join(skill_bits))+ return "; ".join(parts)+++def format_teammate_roster_line(info: Dict[str, Any]) -> str:+ """The one line a lead sees per teammate, shared by both runtimes.++ ``- <node_id>: <label> (<node_type>) - <capabilities>``. The capability+ clause is what lets a lead match work to the agent holding the right+ tool; without it a teammate labelled "Web Agent" carrying TikHub is+ indistinguishable from one carrying nothing.+ """+ line = f"- {info.get('node_id')}: {info.get('label') or info.get('node_type')} ({info.get('node_type')})"+ capabilities = str(info.get("capabilities") or "").strip()+ return f"{line} - {capabilities}" if capabilities else line++async def collect_teammate_connections(node_id: str,context: Dict[str, Any],@@ -557,7 +680,11 @@ async def collect_teammate_connections() -> List[Dict[str, Any]]:"""Walk ``input-teammates`` edges and return connected agents.- Used by ``orchestrator_agent`` / ``ai_employee``.+ Used by ``orchestrator_agent`` / ``ai_employee``. Each teammate carries+ its ``child_tools`` (``input-tools`` edges), ``child_skills``+ (``input-skill`` edges) and a rendered ``capabilities`` sentence: the+ text the lead's roster shows, since the delegate tools themselves are+ hidden from the lead's model."""teammates: List[Dict[str, Any]] = []descriptors = build_teammate_descriptors(node_id, context)@@ -577,7 +704,14 @@ async def collect_teammate_connections("node_type": child.get("type"),"label": (child.get("data") or {}).get("label", child.get("type")),})- teammates.append({**descriptor, "parameters": params, "child_tools": child_tools})+ child_skills = await _teammate_child_skills(source_id, nodes, edges, database)+ teammates.append({+ **descriptor,+ "parameters": params,+ "child_tools": child_tools,+ "child_skills": child_skills,+ "capabilities": describe_teammate_capabilities(child_tools, child_skills),+ })logger.debug(f"[Teams] Found teammate: {descriptor['node_type']} ({source_id})")return teammatesdiff --git a/server/services/temporal/agent_activities.py b/server/services/temporal/agent_activities.pyindex 7fd53744..8aad4769 100644--- a/server/services/temporal/agent_activities.py+++ b/server/services/temporal/agent_activities.py@@ -1109,10 +1109,10 @@ async def prepare_agent_payload(context: Dict[str, Any]) -> Dict[str, Any]:)if any(tool["name"].startswith("delegate_to_") for tool in tools_payload):+ from services.plugin.edge_walker import format_teammate_roster_line+delegates = "\n".join(- f"- {(tool.get('tool_info') or {}).get('node_id')}: "- f"{(tool.get('tool_info') or {}).get('label', tool['node_type'])} "- f"({tool['node_type']})"+ format_teammate_roster_line({**(tool.get("tool_info") or {}), "node_type": tool["node_type"]})for tool in tools_payloadif tool["name"].startswith("delegate_to_"))diff --git a/server/skills/assistant/subagent-skill/SKILL.md b/server/skills/assistant/subagent-skill/SKILL.mdindex 5fec3f49..0a833f9c 100644--- a/server/skills/assistant/subagent-skill/SKILL.md+++ b/server/skills/assistant/subagent-skill/SKILL.md@@ -41,6 +41,12 @@ durable runner continues the work and `taskTrigger` starts the later review.## Capability matching+Every line in the connected teammate list ends with that agent's connected+tools and skills, for example+`- web_1: Web Agent (aiAgent) - tools: TikHub (Scrape TikTok, Douyin, ...); skills: tikhub-skill (...)`.+Match the work to those tools and skills first; the agent type is only a+fallback when the line carries no capability clause.+- Android agents: connected Android device services.- Coding agents: implementation, code analysis, tests, and computation.- Web agents: browsing, HTTP, extraction, and web interaction.diff --git a/server/skills/web_agent/tikhub-skill/SKILL.md b/server/skills/web_agent/tikhub-skill/SKILL.mdindex a920b5cf..d0177c84 100644--- a/server/skills/web_agent/tikhub-skill/SKILL.md+++ b/server/skills/web_agent/tikhub-skill/SKILL.md@@ -333,6 +333,24 @@ paste the key from the TikHub user portal (tikhub.io -> API Keys) andclick Validate - the modal shows the account email and balance when thekey is accepted.+## Working inside a team++When this node is wired to a teammate rather than directly to the lead, the+lead never sees the `tikhub_action` tool itself. It sees one roster line per+teammate that lists the teammate's connected tools and skills, built from+this node's description and this skill's description, and it assigns work+through `task_manager` with a bounded mission. As the teammate holding+TikHub:++1. Treat the mission as the query: pick the platform from the URL or the+ wording, run `list_endpoints` if the endpoint id is not obvious, then+ `call` or `fetch_url`.+2. Return the extracted fields the mission asked for, not the raw TikHub+ payload. Include the endpoint id used, the count of items, and the total+ `cost_usd` so the lead can report spend.+3. If the key is missing or the balance is exhausted, say so in the result+ verbatim so the lead can escalate to the user; do not retry blindly.+## Best practices1. **Prefer `fetch_url` for any share URL.** One request, no iddiff --git a/server/tests/test_team_topology.py b/server/tests/test_team_topology.pyindex f625dd78..a8153e67 100644--- a/server/tests/test_team_topology.py+++ b/server/tests/test_team_topology.py@@ -108,3 +108,57 @@ def test_import_remap_normalizes_legacy_handle():_, [remapped], _ = remap_node_ids(nodes, [edge("worker", "lead", legacy=True)])assert remapped["targetHandle"] == "input-teammates"assert "target_handle" not in remapped+++async def test_teammate_capabilities_surface_tools_and_skills():+ """The lead's roster is the only place a teammate's tools and skills are+ visible (delegate tools are hidden from the lead's model), so the+ descriptor must carry a rendered capability sentence built from the+ tool plugin's description and the enabled Master Skill descriptions."""+ from services.plugin.edge_walker import describe_teammate_capabilities, format_teammate_roster_line++ nodes = [+ node("lead", "orchestrator_agent"),+ node("web", "aiAgent", "Web Agent"),+ node("tikhub", "tikhubAction", "TikHub"),+ node("skills", "masterSkill", "Master Skill"),+ ]+ edges = [edge("web", "lead"), edge("tikhub", "web", "input-tools"), edge("skills", "web", "input-skill")]+ params = {+ "skills": {+ "skills_config": {+ "skill": {"enabled": True, "required": True},+ "assistant-personality": {"enabled": True},+ "tikhub-skill": {"enabled": True},+ "apify-skill": {"enabled": False},+ }+ }+ }+ database = AsyncMock()+ database.get_node_parameters.side_effect = lambda node_id: params.get(node_id, {})++ [teammate] = await collect_teammate_connections("lead", {"nodes": nodes, "edges": edges}, database)++ assert teammate["child_tools"] == [{"node_id": "tikhub", "node_type": "tikhubAction", "label": "TikHub"}]+ assert [s["skill_name"] for s in teammate["child_skills"]] == ["tikhub-skill"]+ assert teammate["child_skills"][0]["description"] # SKILL.md frontmatter text++ capabilities = teammate["capabilities"]+ assert capabilities.startswith("tools: TikHub (")+ assert "Douyin" in capabilities # from TikHubActionNode.description+ assert "skills: tikhub-skill (" in capabilities+ assert "assistant-personality" not in capabilities and "apify-skill" not in capabilities+ assert capabilities == describe_teammate_capabilities(teammate["child_tools"], teammate["child_skills"])++ line = format_teammate_roster_line(teammate)+ assert line.startswith("- web: Web Agent (aiAgent) - tools: TikHub (")+ assert "skills: tikhub-skill" in line+++def test_roster_line_omits_empty_capabilities():+ from services.plugin.edge_walker import format_teammate_roster_line++ bare = {"node_id": "x", "label": "Coder", "node_type": "coding_agent"}+ assert format_teammate_roster_line(bare) == "- x: Coder (coding_agent)"+ assert format_teammate_roster_line({**bare, "capabilities": ""}) == "- x: Coder (coding_agent)"