HiveLang v5Advanced
Parallel Execution & Error Handling
Build fast, resilient agents with concurrency and error boundaries.
Parallel Blocks
The parallel keyword allows multiple tool calls to execute concurrently. This dramatically reduces latency when calling multiple APIs.
Performance: If you have 3 API calls that each take 1 second, running them in parallel takes ~1 second total instead of 3 seconds sequentially.
parallel-example.hive
bot FastSearcher {
capabilities {
web.search
news.search
scholar.search
}
on user.message {
parallel {
call web.search with { query: input } as web_results
call news.search with { query: input } as news_results
call scholar.search with { query: input } as academic_results
}
respond with "Web: " + web_results + "\nNews: " + news_results + "\nAcademic: " + academic_results
}
}
Error Handling (retry / fallback)
Wrap a call in retry to automatically re-attempt it with backoff, and add a fallback block for when it still fails. This prevents your bot from crashing when external services are down.
try-example.hive
bot ResilientBot {
capabilities {
external.api
}
on user.message {
// retry runs the call, retrying with backoff; if it still fails,
// the fallback block runs instead.
response = "Default value"
retry call external.api with { data: input }
with backoff exponential max attempts 3
fallback {
log "external.api failed, using default"
}
respond with "Result: " + response
}
}
Combining Parallel + Error Handling
You can nest retry/fallback inside parallel blocks for maximum resilience and speed.
combined-example.hive
bot ProBot {
capabilities {
api.fastService
api.slowService
}
on user.message {
// Run both calls concurrently...
parallel {
call api.fastService with { query: input } as fast
call api.slowService with { query: input } as slow
}
// ...then retry just the flaky one, with a fallback if it still fails.
fast_final = fast
retry call api.fastService with { query: input } as fast_final
with backoff exponential max attempts 2
fallback { log "fastService still down" }
respond with "Fast: " + fast_final + ", Slow: " + slow
}
}