feat: Add inter-profile orchestration with conversation history#3754
feat: Add inter-profile orchestration with conversation history#3754eloklam wants to merge 5 commits into
Conversation
14fb56d to
8a45ea0
Compare
|
I initially merged PR #3750 (per-call model/provider override on delegate_task by HenkDz) into this branch for my local testing, but have since reverted it from the remote branch. Why: PR #3750 is a separate feature by another contributor that I have no affiliation with. It doesn't belong in my orchestration PR. My agent merged it locally to test both features together on my PC, but accidentally pushed it to GitHub. This revert restores my branch to contain only my own inter-profile orchestration work Thank you! |
|
Got no idea what happened here. |
0671a40 to
0176061
Compare
🆕 What's New Since Initial PushCross-Profile Search:
Naming Convention Fixed:
Delegated agent awareness:
Control Mechanisms:
Depth Tracking:
Natural Language Usage:
|
0176061 to
f7b8cfb
Compare
- Profile discovery and health checking - Port resolution and gateway lifecycle - sync/async HTTP delegation via OpenAI-compatible API - SQLite persistence for async tasks - Conversation history passing between profiles
…tion - HTTP-based delegation to persistent profile workers - Async mode with task tracking via check_profile_task/cancel_profile_task - Conversation history extraction and passing - allow_subagents parameter for user control
- Detect X-Hermes-Delegation headers - Inject delegation context into user messages - Format: <DELEGATED from profile X | delegate_task ALLOWED> - Depth tracking for recursion prevention (MAX_DEPTH=2) - <TASK-COMPLETED> footer requirement - ~77% token reduction vs original format
- SQLite table for async delegation tasks - Schema version bump to 7 - Supports task status tracking across process restarts
- delegate_task, delegate_to_profile tools - check_profile_task, cancel_profile_task for async management - Included in hermes-gateway toolset
f7b8cfb to
9d0188d
Compare
Summary
Add inter-profile orchestration tools enabling one Hermes profile to delegate tasks to another via HTTP, with full conversation history passing between calls.
New Tools (4 total)
profile_delegateprofile_task_checkprofile_task_cancelprofile_task_searchInstall
Enable
delegationtoolset in profile config:Enable api_server on worker profile:
Usage
Key Features
Delegated agent awareness - Delegated agents now know they're delegated agents and not talking to human users, with visual
<DELEGATED from profile X | delegate_task ALLOWED>header.Cross-Profile Search -
profile_task_searchsearches across ALL profiles' task histories, not just the current one. Auto-detects task ID prefixes (e.g., "abc123") vs natural language queries.Configurable Depth - Prevent infinite delegation chains with
max_depthparameter (default 2).Delegated agent control - Use
allow_subagents=Falseto force workers to do all work themselves without spawning one-off subagents.Awareness format
Agent: "p1 (profile, not human) delegated this. I am allowed to use delegate_task."
Control Mechanisms
allow_subagents=True/False— choose if worker can spawn one-off subagentsmax_depth=N— configurable delegation depth (default 2)<TASK {id} COMPLETED>footer for completion correlationDepth Tracking
X-Hermes-Delegate-Depthheader tracks recursion levelX-Hermes-Max-Depthheader sets limit (configurable)depth >= max_depthCross-Profile Natural Language Search
profile_task_search("security issues auth.py")— search across all profilessource_profilefield identifying which profile handled itLIKE task_id%+LIKE %query%on goal/result; natural language uses full-text searchThe agent uses ThreadPoolExecutor for reliability instead of aiohttp (which caused asyncio race conditions). Async tasks persist to SQLite so they survive process restarts. If a task isn't found in memory, it falls back to SQLite lookup.
Files
tools/profile_orchestrator.pytools/delegate_tool.pyprofile_delegate,profile_task_check,profile_task_cancel,profile_task_searchtoolsgateway/platforms/api_server.py<DELEGATED>header injection and depth trackinghermes_state.pyorchestration_taskstable + FTS5 index + ID detection searchtoolsets.pydelegationtoolset with new profile orchestration toolsTests
Handler loads correctly, passes 72 consecutive calls with 100% success rate. Manual testing on Linux (Ubuntu 22.04). Uses stdlib only, no Unix-specific code.
<TASK {id} COMPLETED>detection: ✅allow_subagents=Falseshows NOT ALLOWED: ✅Related
Notes
No configuration needed beyond enabling the toolset and api_server — just create profiles and delegate. The orchestrator automatically discovers worker profiles via
list_profiles(). If a worker isn't running, it starts automatically via subprocess withHERMES_HOMEoverride. No worker running = delegation fails gracefully with error message.Architecture
hermes_cli/profiles.py(from PR feat: add profiles — run multiple isolated Hermes instances #3681)profile_orchestrator.pyimports fromhermes_cli.profiles:get_profile_dir(),ProfileInfo,_check_gateway_running()