Fold BaseTask.handoff_to into activate_task(deactivate_self=...)

BaseTask.handoff_to was just deactivate_self + activate_task. Remove
it and add a deactivate_self flag on activate_task instead, so there's
one entry point for activating another task.

LLMTask now overrides activate_task (mirroring its end() override) to
keep the messages / result_callback hooks that finish an in-progress
tool call before the target is activated. All multi-task examples and
unit tests switch to the new call.
This commit is contained in:
Aleix Conchillo Flaqué
2026-05-20 15:50:03 -07:00
parent e8bbb5ee09
commit 373894fc65
8 changed files with 39 additions and 50 deletions

View File

@@ -122,11 +122,10 @@ class AcmeLLMTask(LLMTask):
reason (str): Why the user is being transferred.
"""
logger.info(f"Task '{self.name}': transferring to '{agent}' ({reason})")
await self.handoff_to(
await self.activate_task(
agent,
activation_args=LLMTaskActivationArgs(
messages=[{"role": "developer", "content": reason}]
),
args=LLMTaskActivationArgs(messages=[{"role": "developer", "content": reason}]),
deactivate_self=True,
result_callback=params.result_callback,
)

View File

@@ -104,11 +104,10 @@ class AcmeLLMTask(LLMTask):
reason (str): Why the user is being transferred.
"""
logger.info(f"Task '{self.name}': transferring to '{agent}' ({reason})")
await self.handoff_to(
await self.activate_task(
agent,
activation_args=LLMTaskActivationArgs(
messages=[{"role": "developer", "content": reason}]
),
args=LLMTaskActivationArgs(messages=[{"role": "developer", "content": reason}]),
deactivate_self=True,
result_callback=params.result_callback,
)