Documentation Index
Fetch the complete documentation index at: https://docs.illa.io/llms.txt
Use this file to discover all available pages before exploring further.
Cancellation is supported at both request and polling levels.
Cancel sendMessage
IllaSDK.sendMessage accepts an abort signal via the fourth argument.
const controller = new AbortController()
const pending = sdk.sendMessage(
'Check my balance',
{ chatId },
undefined,
{ signal: controller.signal },
)
setTimeout(() => controller.abort(), 1_000)
const result = await pending
if (result.response.isError) {
console.error('Request failed or was aborted:', result.response.error)
}
Cancel sendMessageStreaming
sendMessageStreaming accepts signal in its streaming options.
const controller = new AbortController()
const pending = sdk.sendMessageStreaming(
'Swap 0.1 ETH to USDC',
{ chatId },
{
signal: controller.signal,
onEvent: (event) => console.log(event.type),
onError: (error) => console.error(error),
},
)
setTimeout(() => controller.abort(), 1_000)
try {
await pending
} catch (error) {
console.error('Streaming request stopped:', error)
}
Cancel provider-level requests
CoreApiProvider.sendMessage and CoreApiProvider.awaitTransaction also accept signal.
const ac = new AbortController()
const pending = provider.sendMessage(body, { signal: ac.signal })
ac.abort()
await pending
Apply the same pattern to provider.awaitTransaction(params, { signal: ac.signal }).
Stop polling subscriptions
subscribeToToolStatus and AsyncToolChecker.subscribe return a subscription with unsubscribe().
const sub = sdk.subscribeToToolStatus(
{
toolName: 'swap',
protocol: 'lifi',
descriptor: { txHash: '0x...' },
},
{
onStatusChange: ({ current }) => console.log(current.pollStatus),
onError: (error) => console.error(error),
},
)
sub.unsubscribe()
Notes
sendToolResult and sendToolResults do not currently accept an abort signal.
- Always wire cancellation to route changes and component unmounts.