MCPcopy Create free account
hub / github.com/HKUDS/OpenSpace / execute_task

Function execute_task

openspace/mcp_server.py:531–621  ·  view source on GitHub ↗

Execute a task with OpenSpace's full grounding engine. OpenSpace will: 1. Auto-register bot skills from skill_dirs (if provided) 2. Search for relevant skills (scope controls local vs cloud+local) 3. Attempt skill-guided execution → fallback to pure tools 4. Auto-analyze → auto-

(
    task: str,
    workspace_dir: str | None = None,
    max_iterations: int | None = None,
    skill_dirs: list[str] | None = None,
    search_scope: str = "all",
)

Source from the content-addressed store, hash-verified

529# MCP Tools (4 tools)
530@mcp.tool()
531async def execute_task(
532 task: str,
533 workspace_dir: str | None = None,
534 max_iterations: int | None = None,
535 skill_dirs: list[str] | None = None,
536 search_scope: str = "all",
537) -> str:
538 """Execute a task with OpenSpace's full grounding engine.
539
540 OpenSpace will:
541 1. Auto-register bot skills from skill_dirs (if provided)
542 2. Search for relevant skills (scope controls local vs cloud+local)
543 3. Attempt skill-guided execution → fallback to pure tools
544 4. Auto-analyze → auto-evolve (FIX/DERIVED/CAPTURED) if needed
545
546 If skills are auto-evolved, the response includes ``evolved_skills``
547 with ``upload_ready: true``. Call ``upload_skill`` with just the
548 ``skill_dir`` + ``visibility`` to upload — metadata is pre-saved.
549
550 Note: This call blocks until the task completes (may take minutes).
551 Set MCP client tool-call timeout ≥ 600 seconds.
552
553 Args:
554 task: The task instruction (natural language).
555 workspace_dir: Working directory. Defaults to OPENSPACE_WORKSPACE env.
556 max_iterations: Max agent iterations (default: 20).
557 skill_dirs: Bot's skill directories to auto-register so OpenSpace
558 can select and track them. Directories are re-scanned
559 on every call to discover skills created since the last
560 invocation.
561 search_scope: Skill search scope before execution.
562 "all" (default) — local + cloud; falls back to local
563 if no API key is configured.
564 "local" — local SkillRegistry only (fast, no cloud).
565 """
566 try:
567 openspace = await _get_openspace()
568
569 # Re-scan host skill directories (from env) to pick up skills
570 # created by the host bot since the last call.
571 host_skill_dirs_raw = os.environ.get("OPENSPACE_HOST_SKILL_DIRS", "")
572 if host_skill_dirs_raw:
573 env_dirs = [d.strip() for d in host_skill_dirs_raw.split(",") if d.strip()]
574 if env_dirs:
575 await _auto_register_skill_dirs(env_dirs)
576
577 # Auto-register bot skill directories (from call parameter)
578 if skill_dirs:
579 await _auto_register_skill_dirs(skill_dirs)
580
581 # Determine where CAPTURED skills should be written.
582 # Prefer the explicit skill_dirs parameter (= calling host agent's dir),
583 # then fall back to the first env-based host skill dir.
584 capture_skill_dir: str | None = None
585 if skill_dirs:
586 capture_skill_dir = skill_dirs[0]
587 elif host_skill_dirs_raw:
588 first_env = next(

Callers

nothing calls this directly

Calls 9

_get_openspaceFunction · 0.85
_cloud_search_and_importFunction · 0.85
_write_upload_metaFunction · 0.85
_format_task_resultFunction · 0.85
_json_okFunction · 0.85
_json_errorFunction · 0.85
getMethod · 0.80
executeMethod · 0.45

Tested by

no test coverage detected