Skip to content

AccountBalanceQuery returns stale data on testnet after CryptoTransfer #614

@jmgomezl

Description

@jmgomezl

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

  1. Deploy an agent with a dedicated account (e.g. 0.0.8324060)
  2. Fund the account with 10 HBAR via HashPack wallet transfer
  3. Immediately ask the agent to check its balance using get_hbar_balance_query_tool
  4. The tool returns the pre-funding balance (0.74 HBAR) instead of the actual balance (10.74 HBAR)
  5. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions