31 lines
1.1 KiB
Python
31 lines
1.1 KiB
Python
"""Delegate tool: bridges chat brain to execution brain.
|
|
|
|
When the chat model needs to run commands, edit files, or do anything
|
|
requiring system-level access, it calls this tool. The task is passed
|
|
to the execution brain (Claude Code CLI) which has full tool access.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from . import tool
|
|
|
|
|
|
@tool(
|
|
"delegate_task",
|
|
description=(
|
|
"Delegate a complex task to the execution brain (Claude Code CLI). "
|
|
"Use this when you need to: run shell commands, read/write/edit files, "
|
|
"check system status, inspect the codebase, or perform any system-level "
|
|
"operation. Describe the task clearly and the execution brain will carry "
|
|
"it out using its full tool suite (Bash, Read, Edit, Write, Glob, Grep)."
|
|
),
|
|
category="system",
|
|
)
|
|
def delegate_task(task_description: str, ctx: dict | None = None) -> str:
|
|
"""Delegate a task to the execution brain."""
|
|
if not ctx or "agent" not in ctx:
|
|
return "Error: delegate tool requires agent context."
|
|
|
|
agent = ctx["agent"]
|
|
return agent.execute_task(task_description)
|