Skip to main content

Module background_tasks

Module background_tasks 

Source
Expand description

Background tool execution.

With AgentConfig::background_tasks set, tool calls can run detached from the turn that requested them. The model selects background execution per call through a _background_execution property added to each eligible tool’s schema (the agentic policy, by default for every tool), or a tool always or never runs in the background. A detached call returns a dispatch acknowledgement at once; its result is delivered later as a synthetic manage_background_task get call, before the next model call or at the end of the invocation. By default the invocation waits for its tasks.

use strands::Agent;
use strands::background_tasks::BackgroundTasksConfig;
use strands::testing::MockModel;

let agent = Agent::builder()
    .model(MockModel::new())
    .background_tasks(BackgroundTasksConfig {
        always: Some(vec!["slow_report".into()]),
        max_concurrency: Some(2),
        ..Default::default()
    })
    .printer(false)
    .build()?;

Structs§

BackgroundTasksConfig
Background tool execution settings (BackgroundTasksConfig). Tools are named by Tool::name; * matches every tool without an exact entry.
BackgroundTasksConfigBuilder
Use builder syntax to set the inputs and finish with build().