-
Notifications
You must be signed in to change notification settings - Fork 61
AccountBalanceQuery returns stale data on testnet after CryptoTransfer #614
Description
Hey team, first of all thanks for the amazing work on the Agent Kit — it has been a great experience building with it.
We ran into a small issue while building Aivy (aivylabs.xyz) for the APEX Hackathon and wanted to share it in case it helps others or if there is a known workaround we missed.
What happens
After funding an agent account via CryptoTransfer from HashPack, the get_hbar_balance_query_tool returns the old balance for several minutes, while the mirror node API already reflects the correct updated balance.
Steps to reproduce
- Deploy an agent with a dedicated account (e.g. 0.0.8324060)
- Fund the account with 10 HBAR via HashPack wallet transfer
- Immediately ask the agent to check its balance using get_hbar_balance_query_tool
- The tool returns the pre-funding balance (0.74 HBAR) instead of the actual balance (10.74 HBAR)
- Meanwhile, the mirror node endpoint /api/v1/balances?account.id=0.0.8324060 already shows 10.74 HBAR
Expected behavior
AccountBalanceQuery should return the current confirmed balance, especially since CryptoTransfer has sub-second finality on Hedera.
Actual behavior
The balance query returns stale data for several minutes. Repeated calls continue to return the old value. It seems like it might be hitting a consensus node that hasn't propagated the latest state yet.
Environment
- Network: testnet
- Hedera SDK: @hashgraph/sdk (latest)
- Agent Kit: hedera-agent-kit (latest)
- The mirror node (testnet.mirrornode.hedera.com) returns the correct balance immediately
Suggestion
Would it make sense to add a mirror node fallback for balance queries, or at least document this behavior? For applications where users fund accounts and immediately interact with agents, the stale reads create a confusing UX — the UI shows one balance (from mirror node) while the agent reports a different one (from SDK).
Happy to provide more details or help test if needed. Thanks again for all the work on this toolkit, it really made our hackathon project possible.