feat: agent-to-agent handoff and delegation
* feat: add agent-to-agent delegation tool Add `delegate` tool enabling multi-agent workflows where a primary agent can hand off subtasks to specialized sub-agents with different provider/model configurations. - New `DelegateAgentConfig` in config schema with provider, model, system_prompt, api_key, temperature, and max_depth fields - `delegate` tool with recursion depth limits to prevent infinite loops - Agents configured via `[agents.<name>]` TOML sections - Sub-agents use `ReliableProvider` with fallback API key support - Backward-compatible: empty agents map when section is absent Closes #218 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: encrypt agent API keys and tighten delegation input validation Address CodeRabbit review comments on PR #224: 1. Agent API key encryption (schema.rs): - Config::load_or_init() now decrypts agents.*.api_key via SecretStore - Config::save() encrypts plaintext agent API keys before writing - Updated doc comment to document encryption behavior - Added tests for encrypt-on-save and plaintext-when-disabled 2. Delegation input validation (delegate.rs): - Added "additionalProperties": false to schema - Added "minLength": 1 for agent and prompt fields - Trim agent/prompt/context inputs, reject empty after trim - Added tests for blank agent, blank prompt, whitespace trimming Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(delegate): replace mutable depth counter with immutable field - Replace `current_depth: Arc<AtomicU32>` with `depth: u32` set at construction time, eliminating TOCTOU race and cancel/panic safety issues from fetch_add/fetch_sub pattern - When sub-agents get their own tool registry, construct via `with_depth(agents, key, parent.depth + 1)` for proper propagation - Add tokio::time::timeout (120s) around provider calls to prevent indefinite blocking from misbehaving sub-agent providers - Rename misleading test whitespace_agent_name_not_found → whitespace_agent_name_trimmed_and_found Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * style: fix rustfmt formatting issues Fixed all formatting issues reported by cargo fmt to pass CI lint checks. - Line length adjustments - Chain formatting consistency - Trailing whitespace cleanup Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Edvard <ecschoye@stud.ntnu.no> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
e04e7191ac
commit
c8ca6ff059
6 changed files with 764 additions and 7 deletions
|
|
@ -396,6 +396,8 @@ pub async fn run(
|
|||
mem.clone(),
|
||||
composio_key,
|
||||
&config.browser,
|
||||
&config.agents,
|
||||
config.api_key.as_deref(),
|
||||
);
|
||||
|
||||
// ── Resolve provider ─────────────────────────────────────────
|
||||
|
|
@ -470,6 +472,14 @@ pub async fn run(
|
|||
"Execute actions on 1000+ apps via Composio (Gmail, Notion, GitHub, Slack, etc.). Use action='list' to discover, 'execute' to run, 'connect' to OAuth.",
|
||||
));
|
||||
}
|
||||
if !config.agents.is_empty() {
|
||||
tool_descs.push((
|
||||
"delegate",
|
||||
"Delegate a subtask to a specialized agent. Use when: a task benefits from a different model \
|
||||
(e.g. fast summarization, deep reasoning, code generation). The sub-agent runs a single \
|
||||
prompt and returns its response.",
|
||||
));
|
||||
}
|
||||
let mut system_prompt = crate::channels::build_system_prompt(
|
||||
&config.workspace_dir,
|
||||
model_name,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue