Skip to content

feat: cognitive-mesh handoff — delegate complex tasks via retort run cogmesh #490

Description

@JustAGhosT

Summary

Extend retort run to delegate complex, multi-step tasks to cognitive-mesh via its HTTP API — the deep-research analog for the phoenixvc agent ecosystem.

Motivation

Simple tasks suit local CLI dispatch (claude, codex, cursor). Some tasks warrant structured multi-perspective reasoning, ethics/compliance checks, or cross-repo RAG — capabilities that cognitive-mesh already provides through its TaskRouter, IComplexityEscalationPort, and ISandboxFanOutPort ports.

How it works

retort run cogmesh --task "Analyse auth architecture across retort, sluice, mcp-org" \
                   --workflow structured-reasoning \
                   --context .agentkit/spec/

    │
    ▼
cognitive-mesh TaskRouter
    ├─ WorkflowEngine         (multi-step sequential reasoning)
    └─ MultiAgentOrchestration (parallel agent fan-out + synthesis)
         │
         ├─ StructuredReasoning (ConclAIve — Debate & Vote)
         ├─ SecurityReasoning / EthicalReasoning
         ├─ EnhancedRAGSystem (cross-repo knowledge index)
         └─ ISandboxFanOutPort (isolated parallel passes)
              │
              ▼
    Result written to:
      .claude/state/tasks/<id>/result.json  (local)
      phoenix-flow task update              (if --remote, see #489)

Escalation trigger

Tasks can be routed to CM automatically via the .retortconfig escalation rules:

escalation:
  rules:
    - if: complexity >= high
      to: cogmesh
      workflow: structured-reasoning
    - if: tags contains security or compliance
      to: cogmesh
      workflow: security-review
    - if: scope contains cross-repo
      to: cogmesh
      workflow: rag-synthesis
  fallback: claude   # if CM unreachable

Or explicitly:

retort run cogmesh --workflow structured-reasoning --task "..."
retort run cogmesh --workflow security-review      --task "..."
retort run cogmesh --workflow rag-synthesis        --task "..."

Cognitive-mesh entry points

CM already exposes:

  • POST /api/cogmesh/tasks — submit a task (workflow + context)
  • GET /api/cogmesh/tasks/{id} — poll status
  • GET /api/cogmesh/tasks/{id}/result — fetch structured result
  • SignalR hub for real-time progress events
  • IMCPToolPort — CM can itself call mcp-org and phoenix-flow as tools during execution

Plugin surface

The retort-plugins IDE panel should show:

  • Active CM workflows with progress (see retort-plugins#X)
  • Escalation history (which tasks were sent to CM and why)
  • CM health badge (reachable / unreachable / degraded)

.retortconfig extension (builds on #488)

cogmesh:
  endpoint: ${COGMESH_URL}
  secret: ${COGMESH_API_SECRET}
  defaultWorkflow: structured-reasoning
  timeout: 300s
  fallback: claude

Acceptance criteria

  • retort run cogmesh --workflow <name> --task <text> dispatches to CM HTTP API
  • Polls or streams task status until completion
  • Writes result to .claude/state/tasks/<id>/result.json
  • Escalation rules in .retortconfig auto-route matching tasks
  • CM unreachable → falls back to configured fallback CLI
  • --remote flag writes result back to phoenix-flow (feat: cross-machine and cross-team orchestration via phoenix-flow MCP #489)
  • Plugin surfaces CM workflow status (retort-plugins)

Dependencies

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions