Skip to content

feat: multi-agent orchestration — GOAP, AgentGraph, ManagerAgent, Swarm, Memory, WebPipeline#690

Open
cluo wants to merge 15 commits intoHmbown:mainfrom
cluo:main
Open

feat: multi-agent orchestration — GOAP, AgentGraph, ManagerAgent, Swarm, Memory, WebPipeline#690
cluo wants to merge 15 commits intoHmbown:mainfrom
cluo:main

Conversation

@cluo
Copy link
Copy Markdown

@cluo cluo commented May 5, 2026

Summary

Adds six new orchestration tools that compose hierarchically:

New tools

Tool Role
goap_plan A* goal-oriented action planning with 12 default dev actions
graph_execute LangGraph-style state machine with conditional routing, checkpoints, streaming
swarm_init Multi-agent topologies (hierarchical/mesh/ring/star/adaptive) with consensus
manager_delegate CrewAI-style hierarchical delegation (create → assign → dispatch → record → synthesize)
memory_store / memory_search Short-term (FIFO), long-term (persistent), entity (KV) memory
web_pipeline Deep crawl (BFS/DFS/BestFirst), BM25 filter, smart chunking

Sub-agent runtime enhancements

Key files

  • crates/tui/src/tools/agent_graph.rs — new
  • crates/tui/src/tools/agent_memory.rs — new
  • crates/tui/src/tools/manager_agent.rs — new
  • crates/tui/src/tools/web_pipeline.rs — new
  • crates/tui/src/core/engine.rs — token counter, handoff prompt, middleware wiring
  • crates/tui/src/tools/subagent/mod.rs — router/profile/middleware wiring
  • crates/tui/src/tools/registry.rs — builder methods
  • crates/tui/src/core/engine/tool_setup.rs — all 6 tools registered in Plan + Agent modes
  • crates/tui/src/prompts/base.md — Toolbox section updated
  • AGENTS.md — Multi-Agent Orchestration section added

Tests

  • 18 new unit tests pass (agent_graph, agent_memory, manager_agent, web_pipeline, goap)
  • 105 subagent tests pass, no regressions
  • Build compiles cleanly

cluo added 10 commits May 5, 2026 05:50
… Thread metadata

- protocol: Add AgentActivityStatus 6-state enum (idle/thinking/tool_calling/
  speaking/error/spawning) + AgentZone 5-zone enum (desk/hot_desk/lounge/
  meeting/corridor)
- protocol: Add Thread.zone + Thread.activity fields
- protocol: Add new EventFrame variants: ThreadActivityChanged, ThreadZoneChanged,
  ThreadSpawned, CollaborationLink
- state: SQL migration ALTER TABLE threads ADD COLUMN zone/activity TEXT
- state: Full CRUD support (SELECT/INSERT/UPDATE/row_to_thread)
- core: spawn_thread_with_history sets zone=Corridor, activity=Spawning
- core: to_protocol_thread serializes zone/activity from persisted metadata

Absorbed from openclaw-office L4 strategy (iteration-001).
…arm, GOAP, A2A, profiles

Phase 3 — Agent orchestration:
- AgentMiddleware trait + MiddlewareChain with @Next/@Prev anchors
- AgentRouter (keyword registry + LLM fallback capability routing)
- CompactionGuard middleware (80% threshold auto-compaction signal)
- ModelRouter (task-type → optimal model selection)

Phase 4 — Multi-provider LLM:
- ProviderKind expanded with Anthropic, Google, Microsoft
- Unified call_llm/stream_llm wrappers with RetryConfig
- ThinkingCapability (5 modes) + ModelMetadata
- ProxyAgent with dual-base-URL + auto-failover

Phase 5 — Multi-agent coordination:
- SwarmTopology (Queen/Mesh/Adaptive) + SwarmConfig
- ConsensusProtocol (Raft/Byzantine/Gossip)
- DebateRole + DebateConfig for two-agent adversarial reasoning

Phase 6 — Planning & profiles:
- GoapPlanner with A* search (GOAP)
- A2aMessage + A2aAdapter protocol
- AgentProfile + ProfileRegistry (6 built-in profiles)
- SubAgentLifecycle, pause/resume, spawn dry_run/concurrency
- Plan checkpoint/restore with Paused/Interrupted states
- NoteTool enhanced with JSON Lines + SHA-256 dedup
- Rename ThinkingMode::Adaptive → Auto
- Add ReasoningEffort (Off/Low/Medium/High/Max) with to_thinking_mode()
- Add TaskComplexity classifier (Lookup/CodeGen/Architecture/Debug)
- Add AutoReasoningSelector evaluating 4 signals:
  1. Task complexity → base effort + model
  2. Cache pressure (< 30% hit → drop one tier)
  3. Cost budget (> 80% spent → throttle to Low)
  4. Sub-agent fanout → always route to flash, cap at Medium
- Explicit override always wins (manual Shift+Tab toggle respected)
- Audit-logging via tracing events on each auto selection
- 12 tests covering classification, throttling, override, fanout
Add HandoffPrompt — structured agent context transfer as a
default replacement for routine compaction:

- HandoffPrompt captures summary, progress, blockers, open_loops,
  working_set, model, timestamp, and token count
- render() produces a stable cache-prefix-ready prompt for the
  successor agent
- Builder pattern: with_summary, add_completed, add_in_progress,
  add_pending, add_blocker, add_open_loop, add_file, with_pct_complete
- Serialize/deserialize for session persistence
- Integrated with CompactionGuard: when context threshold crossed,
  handoff prompt can be generated instead of compacting
- Preserves V4 prefix-cache discount (~90%) vs compaction's ~10× cost
- 3 tests + round-trip serialization

Also export HandoffProgress via subagent module.
Gap 1 — 128-token boundary alignment:
- Add estimate_tokens() and pad_to_128_token_boundary() to prompts
- Conservative 4-char/token heuristic for English prose
- Newline-padding so sections don't shift across cache boundaries
- 4 deterministic alignment tests

Gap 4 — Strict tool mode capability:
- Add StrictToolMode to ToolCapability enum in crates/tools
- Tools can opt-in for schema-validated tool-call JSON
- Recommended for mutating tools (apply_patch, exec_shell, write_file)
Add fim_edit tool:
- Takes path + prefix_anchor + suffix_anchor
- Splits file at anchors, builds FIM prompt for hole-filling
- Supports line numbers and text-content anchors
- Falls back to apply_patch when FIM endpoint unavailable
- StrictToolMode capability for validated tool-call JSON
- 4 tests: anchor finding, prompt structure, schema validation

Also fix: unused import warnings in goap.rs and subagent/mod.rs
Add Auto variant to the TUI's ReasoningEffort enum:
- Shift+Tab cycle: Off → High → Max → Auto → Off
- api_value() returns None for Auto — engine fills via selector
- config_ui ReasoningEffortValue with Auto conversions
- ReasoningEffort::from_setting accepts 'auto'

Now if reasoning_effort = "auto" in config, the app starts in
Auto mode and the engine delegates to AutoReasoningSelector from
llm::reasoning for per-turn effort + model selection.
…peline tools

- agent_graph: LangGraph-style state machine with conditional routing,
  checkpoints, streaming events. Register as graph_execute tool.
- agent_memory: Short-term (FIFO), long-term (persistent), entity (KV)
  memory. Register as memory_store + memory_search tools.
- manager_agent: CrewAI-style hierarchical delegation with create →
  assign → dispatch → record → synthesize lifecycle. Register as
  manager_delegate tool.
- web_pipeline: Deep crawl (BFS/DFS/BestFirst), BM25 content filter,
  smart chunking (sentence/paragraph/heading/fixed). Register as
  web_pipeline tool.
- goap: add GoapPlanTool (ToolSpec) with 12 default dev actions
- swarm: add tool module wiring

All 18 unit tests pass. #![allow(dead_code)] applied to library-style
API surface.
…gent runtime

- engine.rs: shared token_counter, build_middleware_chain(),
  update_token_counter(), build_handoff_prompt() with plan/todo/
  working-set population
- subagent runtime: AgentRouter for auto-routing spawn type,
  ModelRouter for per-type model selection, ProfileRegistry for
  named profiles (code-reviewer, architect, etc.)
- middleware: CompactionGuard reads shared token_counter, flags
  compaction_needed in MiddlewareContext after each step, emits
  progress event when threshold crossed
- profiles: resolve at spawn time, inject posture_prompt into
  agent's first message
- token counter updates on every API response (engine + sub-agents)

Fixes Hmbown#664 (context-limit handoff).
- base.md Toolbox: add goap_plan, swarm_init, manager_delegate,
  memory_store/memory_search, graph_execute, web_pipeline entries
- AGENTS.md: new Multi-Agent Orchestration section with composition
  pattern, key files, and hierarchical layer table
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

cluo added 5 commits May 5, 2026 13:23
Wraps the agent-browser CLI (vercel-labs/agent-browser) as a first-class
DeepSeek-TUI tool. The tool is only registered when agent-browser is
found on PATH (checked once, cached via OnceLock).

Actions covered:
- navigate: open a URL
- snapshot: accessibility tree with @en refs (interactive + compact)
- click, fill, type_text: interact with elements by ref/selector
- screenshot: PNG/JPEG with optional full_page + annotate flags
- get_text, get_url, get_title: extract page data
- wait: element/URL/text/load/JS condition
- evaluate: run arbitrary JavaScript via agent-browser eval --stdin
- press_key, scroll, close

Output parsing: JSON (data.* nested + top-level) + fallback text
extraction for screenshot paths.

For advanced agent-browser commands (tabs, network interception,
auth vault, React DevTools), the model falls back to exec_shell.

Docs: base.md Toolbox + AGENTS.md Browser Automation section added.
Tool registered in Plan and Agent modes via with_browser_tool().

9 unit tests pass.
Wraps the obscura CLI (h4ckf0r0day/obscura) as a ToolSpec for fast,
stealthy JS-rendered page extraction. The tool is only registered when
obscura is found on PATH (cached via OnceLock).

Actions covered:
- fetch: JS-rendered page dump (text/html/links) with optional eval
- scrape: parallel multi-URL extraction with concurrency control
- serve: background CDP WebSocket server for Puppeteer/Playwright

Key features:
- 30 MB memory / instant start vs Chrome's 200 MB / ~2s
- Built-in stealth mode: fingerprint randomization + 3,520-domain
  tracker blocking
- DOM->Markdown via LP.getMarkdown CDP domain
- Complementary to agent-browser: obscura for stealth/scrape,
  browser tool for interactive clicks/forms/screenshots

Docs: base.md Toolbox + AGENTS.md Headless Browser section with
comparison table. Registered in Plan and Agent modes.

4 unit tests pass.
…ive_default)

Auto-applied via .

- agent_graph: #[derive(Default)] for GraphState, is_some_and()
- browser: simplify .map_err(|e| ToolError::execution_failed(e))? to .map_err(ToolError::execution_failed)?
- obscura: same .map_err simplification
- subagent/mod: if let chains with && let, #[derive(Default)] SubAgentLifecycle
- subagent/router: remove ref from pattern
- fim_edit: if let chain
- shell: if let chains in NoteTool
- agent_memory: if let chains
…agency_agents()

Integrates the msitarzewski/agency-agents library (92.9k stars, 144+
specialized AI agent personalities) with DeepSeek-TUI's profile system.

Added:
- ProfileRegistry::import_agency_agents(dir) — bulk import from directory
  of .md files with YAML frontmatter
- parse_yaml_frontmatter() — zero-dependency YAML frontmatter parser
- slugify() — converts 'Frontend Developer' → 'frontend-developer'
- format_agency_posture() — formats body as agent posture prompt
- infer_agent_type() — maps division/content keywords to SubAgentType

Division mapping: Engineering→Implementer, Testing→Verifier,
Design→Implementer, Review→Review, Strategy/Product/PM→Plan, others→General

Usage:
  git clone agency-agents ~/.deepseek/agency-agents/
  agent_spawn { profile: "frontend-developer", prompt: "..." }
  agent_spawn { profile: "security-engineer", prompt: "..." }

Docs: AGENTS.md Agent Profiles section + base.md Toolbox reference
14 unit tests pass (8 existing + 6 new).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant