Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory Hash Synchronization Issue When Switching Machines #140

Open
jfrank-summit opened this issue Jan 15, 2025 · 1 comment
Open

Memory Hash Synchronization Issue When Switching Machines #140

jfrank-summit opened this issue Jan 15, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@jfrank-summit
Copy link
Member

When switching machines for agent execution, the local caching of memory hashes can lead to synchronization issues. The current implementation prioritizes local hash storage:

export const getLastMemoryHash = async (): Promise<string> => {
  const localHash = getLocalHash();
  if (localHash) {
    logger.info('Using locally stored hash', { hash: localHash });
    return localHash;
  }

  const blockchainHash = await contract.getLastMemoryHash(wallet.address);
  if (blockchainHash) {
    saveHashLocally(blockchainHash);
  }
  return blockchainHash;
};

This means when moving to a new machine, we might use outdated local hash data instead of the latest blockchain state from the previous machine.

Proposed Solutions

  1. Session-Based Hash Storage

Generate unique session ID on agent startup
Associate last-hash.json with current session
Clear previous session data on startup

  1. Timestamp-Based Validation

Add timestamp to memory hash events
Compare local hash timestamp with blockchain on startup
Invalidate local cache if blockchain state is newer

@jfrank-summit jfrank-summit added the bug Something isn't working label Jan 15, 2025
@Xm0onh
Copy link
Member

Xm0onh commented Jan 16, 2025

When you are switching machine, you don't have any local memory at the beginning. So your state is going to be the latest state on the blockchain.
However, I think your issue is: sometimes you run on machine A and sometimes on B. In that case, yes, the latest memory in the local file is outdated and will cause synch problem.

Xm0onh added a commit that referenced this issue Jan 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants