Skip to content

Add agent_send_async and agent_cancel tools for non-blocking delegation#797

Open
pbranchu wants to merge 2 commits intoRightNow-AI:mainfrom
pbranchu:feat/async-agent-delegation
Open

Add agent_send_async and agent_cancel tools for non-blocking delegation#797
pbranchu wants to merge 2 commits intoRightNow-AI:mainfrom
pbranchu:feat/async-agent-delegation

Conversation

@pbranchu
Copy link

Summary

  • Add agent_send_async tool that dispatches messages to other agents in the background, returns immediately with a callback_id, and delivers the formatted result via an mpsc channel for channel adapters to consume
  • Add agent_cancel tool to abort pending async tasks by callback_id
  • Add ASYNC_TASKS (DashMap) for tracking/cancelling spawned tasks and ASYNC_RESULT_TX/ASYNC_RESULT_RX channel pair for result delivery to voice/real-time adapters
  • Add take_async_result_receiver() public API for channel adapters to wire up at startup

Test plan

  • cargo build -p openfang-runtime --lib compiles cleanly
  • cargo clippy -p openfang-runtime --lib -- -D warnings passes with zero warnings
  • Live test: send agent_send_async via API, verify callback_id returned immediately and result delivered asynchronously
  • Live test: send agent_cancel with valid callback_id, verify task is aborted

🤖 Generated with Claude Code

Philippe Branchu and others added 2 commits March 23, 2026 04:34
Introduces two new built-in tools:
- agent_send_async: dispatches a message to another agent in the background,
  returns immediately with a callback_id, and delivers the result as a
  follow-up message via an mpsc channel (consumed by channel adapters)
- agent_cancel: aborts a pending async task by callback_id

This enables voice and real-time channel adapters to acknowledge the user
immediately while long-running delegations (email, calendar, etc.) complete
in the background.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- test_async_tool_definitions_exist
- test_async_tool_schema_has_required_params
- test_cancel_tool_schema
- test_agent_send_async_no_kernel_fails
- test_agent_send_async_missing_caller
- test_agent_cancel_missing_callback_id
- test_agent_cancel_nonexistent_task
- test_take_async_result_receiver_returns_once

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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