Skip to main content

Multi-Agent Orchestration

Use A2ATaskDelegator (or SekuireSDK.createDelegator) to route and track delegated work.

import { SekuireSDK } from '@sekuire/sdk';

const sdk = SekuireSDK.fromEnv();
await sdk.start();

const delegator = sdk.createDelegator({
timeout: 60_000,
pollInterval: 1_000,
});

const result = await delegator.delegate({
skill: 'github:issues',
message: 'Create an issue for login timeout regressions.',
traceId: 'trace-123',
});

console.log(result.status, result.agentId, result.taskId);

createDelegator() reuses runtime credentials when available, which improves task registration/completion behavior in fallback flows.

Direct A2ATaskDelegator Setup

Use direct construction only when you need lower-level control than sdk.createDelegator().

import { A2ATaskDelegator } from '@sekuire/sdk';

const delegator = new A2ATaskDelegator({
apiUrl: 'https://api.sekuire.ai',
authToken: process.env.SEKUIRE_API_KEY!,
workspaceId: 'ws_abc123',
agentId: 'agent_orchestrator',
timeout: 60_000,
pollInterval: 1_000,
maxRetries: 2,
retryDelayMs: 1_000,
retryBackoffMultiplier: 2,
tokenResolver: () => process.env.SEKUIRE_RUNTIME_TOKEN,
});

Direct Fallback Target

If routed mode fails, you can provide a direct URL fallback.

const result = await delegator.delegate({
skill: 'incident:summarize',
message: 'Summarize the latest on-call incident',
targetUrl: 'https://incident-agent.internal/a2a',
targetAgentId: 'agent_incident',
});

Streaming Progress

for await (const event of delegator.delegateWithStreaming({
skill: 'document:summarize',
message: 'Summarize this runbook',
})) {
console.log(event.status, event.message?.parts);
}

Cancellation

delegator.cancelDelegation('task_id_here');
// or
// delegator.cancelAllDelegations();

LLM-Accessible Discovery/Delegation Tools

Use createDiscoveryTool and createDelegationTool to expose orchestration as callable tools.

import {
SekuireClient,
createDelegationTool,
createDiscoveryTool,
generateKeyPair,
} from '@sekuire/sdk';

const client = new SekuireClient(generateKeyPair(), {
registryUrl: 'https://api.sekuire.ai',
apiKey: process.env.SEKUIRE_API_KEY,
});

const discoverAgents = createDiscoveryTool(client);
const delegateTask = createDelegationTool(client);

console.log(discoverAgents.name, delegateTask.name);

Next Steps