Skip to content

feat(delegation): agent profiles for delegate_task (#9459)#18522

Open
w87x wants to merge 3 commits into
NousResearch:mainfrom
w87x:feat/agent-profiles-9459
Open

feat(delegation): agent profiles for delegate_task (#9459)#18522
w87x wants to merge 3 commits into
NousResearch:mainfrom
w87x:feat/agent-profiles-9459

Conversation

@w87x

@w87x w87x commented May 1, 2026

Copy link
Copy Markdown

Allow delegate_task to spawn subagents from named agent profiles defined in agent_profiles (config.yaml). Profiles configure model, toolsets, max_iterations, system prompt, and delegation credentials.

  • _load_agent_profile() / _resolve_profile_system_prompt() helpers
  • _build_child_agent() gains profile_cfg param
  • delegate_task() gains profile param (top-level + per-task in batch)
  • build_delegate_task_schema() injects live profile list into tool schema
  • Orchestrator system prompts list available profiles for routing
  • agent_profiles: {} added to config defaults and _KNOWN_ROOT_KEYS
  • cli-config.yaml.example documents schema with 4 example profiles
  • 34 unit tests covering all new code paths

Closes #9459

What does this PR do?

Related Issue

Fixes #

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

How to Test

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform:

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

For New Skills

  • This skill is broadly useful to most users (if bundled) — see Contributing Guide
  • SKILL.md follows the standard format (frontmatter, trigger conditions, steps, pitfalls)
  • No external dependencies that aren't already available (prefer stdlib, curl, existing Hermes tools)
  • I've tested the skill end-to-end: hermes --toolsets skills -q "Use the X skill to do Y"

Screenshots / Logs

Allow delegate_task to spawn subagents from named agent profiles
defined in agent_profiles (config.yaml). Profiles configure model,
toolsets, max_iterations, system prompt, and delegation credentials.

- _load_agent_profile() / _resolve_profile_system_prompt() helpers
- _build_child_agent() gains profile_cfg param
- delegate_task() gains profile param (top-level + per-task in batch)
- build_delegate_task_schema() injects live profile list into tool schema
- Orchestrator system prompts list available profiles for routing
- agent_profiles: {} added to config defaults and _KNOWN_ROOT_KEYS
- cli-config.yaml.example documents schema with 4 example profiles
- 34 unit tests covering all new code paths

Closes NousResearch#9459
@alt-glitch alt-glitch added type/feature New feature or request P3 Low — cosmetic, nice to have comp/agent Core agent loop, run_agent.py, prompt builder tool/delegate Subagent delegation area/config Config system, migrations, profiles labels May 1, 2026
@davidgut1982

Copy link
Copy Markdown
Contributor

Hey @w87x — we independently implemented the same feature in #32630 (now closed in favor of this one). Your implementation is more complete: the model_tools.py dynamic schema patch and orchestrator prompt injection are the right approach. We validated the pattern in production on our homelab Hermes instance — automatic intent routing via SOUL.md works cleanly with named profiles.

We have 17 additional tests that cover some edge cases (max_iterations dead assignment at top-level call site, deepcopy isolation, int coercion on bad YAML values). Happy to contribute them here if useful. Let me know if you'd like a PR against your branch.

@gutleib

gutleib commented May 29, 2026

Copy link
Copy Markdown

Hey @w87x — great work on agent profiles. I implemented a complementary approach in #34754 and want to sync up rather than duplicate effort.

Overlap:
Both PRs solve the same core problem (named subagent configurations in config.yaml -> delegate_task(profile=...)), with similar mechanics: model override, toolsets scoping, system prompt injection, and schema injection so the orchestrating LLM sees available profiles.

Where #34754 extends yours:

Aspect #18522 (agent_profiles) #34754 (delegation.profiles)
Config location Top-level agent_profiles: delegation.profiles: (inherits delegation.* defaults)
ACP routing Not present acp_command/acp_args per profile — local agent runners (Claude Code, aider, etc.)
constraints field Not present Dedicated constraints: section prepended before task instruction
Lazy credential resolution Resolves creds eagerly ACP-only profiles skip credential lookup entirely
Credential caching Resolves per-task Caches per profile name across batch tasks
Batch validation Per-task All profiles validated before any child spawns
toolsets: [] semantics Inherits parent Empty array is respected (not overwritten by parent tools)
System prompt Replaces whole child prompt Replaces only first line (preserves task/depth/workspace infrastructure)
Proxy stub Not present proxy: field accepted, logged but not wired (v2 placeholder)

Config namespace question:
Yours uses agent_profiles (top-level), mine uses delegation.profiles (nested). The issue #9459 proposes agent_profiles. I nested under delegation because profiles inherit max_iterations, max_spawn_depth etc. from delegation defaults naturally — but happy to move to agent_profiles if that's the consensus. That's a one-line _load_config() change.

Proposal:
Let's figure out which parts to merge where. I'm happy to:

  1. Port my ACP routing and constraints onto your agent_profiles config shape if you prefer that namespace
  2. Or merge your system_prompt_file support into mine
  3. Or combine both — your solid foundation + my ACP/constraints/lazy-creds extras

What do you think is the cleanest path to one merged PR that covers both use cases?

Tests: 35 new tests in #34754, all pass under scripts/run_tests.sh. Would also be happy to port our tests to whichever branch wins.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/config Config system, migrations, profiles comp/agent Core agent loop, run_agent.py, prompt builder P3 Low — cosmetic, nice to have tool/delegate Subagent delegation type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(delegation): agent profiles for delegate_task — custom orchestration harness support

4 participants