Skip to content

feat: add agent_profiles support for delegate_task (closes #9459)#32630

Closed
davidgut1982 wants to merge 3 commits into
NousResearch:mainfrom
davidgut1982:feat/agent-profiles-9459
Closed

feat: add agent_profiles support for delegate_task (closes #9459)#32630
davidgut1982 wants to merge 3 commits into
NousResearch:mainfrom
davidgut1982:feat/agent-profiles-9459

Conversation

@davidgut1982

@davidgut1982 davidgut1982 commented May 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements named agent profile presets for delegate_task(), resolving Issue #9459.

Profiles are defined in config.yaml under agent_profiles: and can be referenced per-delegation or per-task. Each profile supports:

  • model — override the child agent model
  • toolsets — restrict the child agent's available tools (MCP scoping)
  • max_iterations — cap the child agent's turn depth
  • system_prompt / system_prompt_file — replace the child's default prompt (leaf workers)

Usage

# config.yaml
agent_profiles:
  email_checker:
    model: openai/gpt-4o-mini
    toolsets: ["mcp-gmail"]
    max_iterations: 5
  web_researcher:
    model: anthropic/claude-3-5-sonnet
    toolsets: ["mcp-search", "mcp-exa"]
# In a tool call or agent config
delegate_task(goal="check my inbox", profile="email_checker", parent_agent=agent)

Implementation Notes

  • _load_profiles() reads from load_config() — no new config file, just a new root key
  • _resolve_profile() handles system_prompt_file expansion, max_iterations int coercion, and deep-copies the profile dict to prevent mutation
  • Profile max_iterations is applied at both top-level and per-task call sites (top-level was a dead assignment in the naive implementation — fixed)
  • system_prompt in a profile replaces the entire child prompt (including orchestrator delegation instructions); documented in schema with WARNING; intended for leaf workers only
  • setattr(child, "ephemeral_system_prompt", ...) used consistently with the existing pattern at line ~1265

Tests

152 tests passing (147 original + 5 regression tests for the Code Critic findings).

New test class: TestAgentProfiles with 17 tests covering:

  • Profile resolution (model, toolsets, max_iterations, system_prompt, system_prompt_file)
  • Error paths (unknown profile, missing file, invalid max_iterations type)
  • Integration (profile drives child; explicit params override profile; unknown profile returns error JSON)
  • Regression guards (top-level max_iterations applied; per-task beats top-level; deepcopy isolation; int coercion)

Checklist

  • ruff: All checks passed!
  • 152/152 tests passing
  • 0 net-new Pyright errors (baseline had 38 pre-existing errors in delegate_tool.py)
  • Schema updated with profile parameter documentation and system_prompt replacement warning

Closes #9459

Packaging Note

During production testing on 0.14.0 (installed via PyPI), hermes_cli/secret_prompt.py was found to be absent from the installed package. This caused an ImportError when the tools → config import chain was triggered after deploying the modified config.py. The file exists in the repository but was not included in the PyPI distribution.

If a related issue exists, this PR's testing surfaced the same root cause. If not, it may be worth filing separately against the 0.14.0 release packaging.

davidgut1982 and others added 3 commits May 26, 2026 13:22
…egate_task

Implements NousResearch#9459. Allows named agent profiles in config.yaml with per-profile
model, toolsets, max_iterations, and system_prompt overrides. The profile=
parameter in delegate_task() selects a profile as the baseline for a child
agent; explicit call parameters override profile values.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ride

Pyright flags direct attribute assignment on AIAgent for undeclared attrs.
Replace `child.ephemeral_system_prompt = _profile_prompt` with setattr()
to match the read-side pattern (getattr) already used at line 1265 and
suppress the one new type error introduced by the agent_profiles feature.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…opy; type validation

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@davidgut1982 davidgut1982 marked this pull request as draft May 26, 2026 13:48
@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 labels May 26, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Competing implementation with open #18522 — both close #9459 (agent_profiles for delegate_task). Both modify config.py and delegate_tool.py. Recommend coordinating to avoid duplicate work.

@davidgut1982

Copy link
Copy Markdown
Contributor Author

Closing in favor of #18522 which is a superset of this implementation. See comment there for details.

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

Labels

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

2 participants