A3S Docs
A3S CodeExamples

Lane Queue

Priority-based task queue with preemption

Lane Queue

The lane queue provides priority-based task scheduling with four lanes. High-priority tasks preempt lower-priority ones already in the queue.

Lanes (highest → lowest priority)

Prop

Type

Basic Queue Setup

use a3s_code_core::{Agent, SessionOptions, SessionQueueConfig};

let queue_config = SessionQueueConfig::default()
    .with_lane_features()
    .with_metrics();

let opts = SessionOptions::new()
    .with_permissive_policy()
    .with_queue_config(queue_config);

let session = agent.session("/my-project", Some(opts))?;

// Tasks are automatically routed to the appropriate lane
let result = session.send("List all Rust files", None).await?;
println!("{}", result.text);

Run: cargo run --example test_task_priority Source: core/examples/test_task_priority.rs

from a3s_code import SessionQueueConfig

queue_config = SessionQueueConfig()
queue_config.enable_all_features = True

session = agent.session("/my-project",
    permissive=True,
    queue_config=queue_config,
)
result = await session.send("List all Rust files")
print(result.text)

Run: python examples/test_task_priority.py Source: sdk/python/examples/test_task_priority.py

const session = agent.session('/my-project', {
  permissive: true,
  queueConfig: { enableAllFeatures: true },
});
const result = await session.send('List all Rust files');
console.log(result.text);

Run: node examples/test_task_priority.js Source: sdk/node/examples/test_task_priority.js

Priority Preemption

use a3s_code_core::queue::{ExternalTask, SessionLane};

// Submit a low-priority background task
session.submit_task(ExternalTask::new(
    "background-analysis",
    SessionLane::Generate,
    serde_json::json!({ "prompt": "Analyze the entire codebase" }),
)).await?;

// Submit a high-priority query that preempts the background task
session.submit_task(ExternalTask::new(
    "urgent-query",
    SessionLane::Query,
    serde_json::json!({ "prompt": "What is the current git branch?" }),
)).await?;

// urgent-query runs first, background-analysis resumes after
# Submit a low-priority background task
await session.submit_task({
    "id": "background-analysis",
    "lane": "generate",
    "payload": {"prompt": "Analyze the entire codebase"},
})

# Submit a high-priority query that preempts it
await session.submit_task({
    "id": "urgent-query",
    "lane": "query",
    "payload": {"prompt": "What is the current git branch?"},
})
// Submit a low-priority background task
await session.submitTask({
  id: 'background-analysis',
  lane: 'generate',
  payload: { prompt: 'Analyze the entire codebase' },
});

// Submit a high-priority query that preempts it
await session.submitTask({
  id: 'urgent-query',
  lane: 'query',
  payload: { prompt: 'What is the current git branch?' },
});

For full lane queue documentation, see Lane Queue.

API Reference

SessionQueueConfig

Prop

Type

ExternalTask fields (Rust)

Prop

Type

Queue management methods

Prop

Type

On this page