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

EVM Plugin can't run any action #735

Closed
0xaguspunk opened this issue Dec 1, 2024 · 18 comments
Closed

EVM Plugin can't run any action #735

0xaguspunk opened this issue Dec 1, 2024 · 18 comments
Labels
bug Something isn't working

Comments

@0xaguspunk
Copy link
Contributor

Describe the bug

The EVM Plugin actions do not work, they probably never worked.

The code assumes that the options object passed to the handler of the action has all the parameters of the action parsed automagically. It's assuming a tool calling pattern like the one AI SDK offers.

To Reproduce

  1. Add an EVM_PUBLIC_KEY and an EVM_PRIVATE_KEY to run the evmPlugin
  2. Hardcode the balance returned by the wallet provider to 5 ETH.
  3. Build the plugin-evm with pnpm build
  4. Run the agent and use the example prompt from the plugin: Transfer 1 ETH to 0x742d35Cc6634C0532925a3b844Bc454e4438f44e
  5. The agent should fail with error ["⛔ TypeError: Cannot read properties of undefined (reading 'chainId')"]

You can also add a console.log when transfer is called with the params and you will see the content is empty.

Expected behavior
Agent should fail because transaction failed.

Screenshots
Screenshot 2024-12-01 at 02 18 52

@0xaguspunk 0xaguspunk added the bug Something isn't working label Dec 1, 2024
@yourbuddyconner
Copy link

This happens when the Agent is run outside of a browser in a node environment, I have actually been messing with the code and have basic operations working.

This happens because private key wallets don't require the wallet_switchEthereumChain RPC which DeFi apps use in the browser.

If one of the maintainers wants to let me know the intent here I could probably contribute this back upstream.

I am thinking it might be neat to add some settings that allow for it to be switchable between node/browser.

@yourbuddyconner
Copy link

Made some changes in a branch on my fork here in case anyone wants to do some copy-pasta: https://github.com/yourbuddyconner/eliza/tree/conner/evm/packages/plugin-evm/src

I properly set up the LiFi SDK as well as arbitrary ERC20 operations.

@0xaguspunk
Copy link
Contributor Author

Hey @yourbuddyconner

Your changes don't solve the problem for the transfer and bridge actions which still assume that options will automagically include all the needed params.

Seems like you fixed swap and the ones you added do correctly aim to extract the parameters from the message, which is what all the actions should do.

Maybe you can fix transfer and bridge too and submit a PR? I have a few comments on the changes but easier to do that on a PR.

@yourbuddyconner
Copy link

I can look into that this weekend!

@0xCardinalError
Copy link
Contributor

browser

wait, how do you run this in browser, I done see any info on running this AI in browser, just CLI

@0xCardinalError
Copy link
Contributor

Using CLI, I cant even get this action to fire and it says its loaded. All I get is
" ["⚠ No action found in the response content."] "

any help?

@yourbuddyconner
Copy link

@n00b21337 What is your use-case for running in a browser? I can't imagine why I would do that atm...

@yourbuddyconner
Copy link

yourbuddyconner commented Dec 10, 2024

@0xaguspunk -- I added basic working (CLI) functionality to a draft PR here: #952

I only got it to the point where my basic cli tests worked ("send yourself 0.001 ETH on sepolia", "bridge 0.001 ETH from ethereum to base")

This is a bridge tx initiated by my local agent with this code: https://etherscan.io/tx/0x17405e4caf0b93d8eddbd2c3c9f3dc0d7158225ef261f74a304fe178fc3285d8

Needs test coverage, and generally more guidance from the maintainers/users RE: what they'd like to see here (it does what I need it to do right now).

@0xCardinalError
Copy link
Contributor

0xCardinalError commented Dec 10, 2024

This happens when the Agent is run outside of a browser in a node environment, I have actually been messing with the code and have basic operations working.

because you said
"This happens when the Agent is run outside of a browser in a node environment"

so I was assuming I am doing something wrong as I cant get my agent to run any wallet actions, so thought maybe I need to run it in browser env somehow ?! :) guess its not that.

@0xCardinalError
Copy link
Contributor

what i realized now is that default trump char and all of his lore and knowledge made him somehow not even check the Actions, he would just ignore them, when I deleted it all now I at least get the regular

"TypeError: Cannot read properties of undefined (reading 'chainId')"] "

which is where most other were I guess. this is some other issue then. at least I know how to debug basic action now.

@0xaguspunk
Copy link
Contributor Author

Yeah testing actions with the default trump setup is a pain in the butt haha

"TypeError: Cannot read properties of undefined (reading 'chainId')"] "

Yes, that error is the one that should be fixed!

@0xCardinalError
Copy link
Contributor

Yeah testing actions with the default trump setup is a pain in the butt haha

"TypeError: Cannot read properties of undefined (reading 'chainId')"] "

Yes, that error is the one that should be fixed!

why is that? its interesting he skips them even if perfectly "matched" with keywords. he doesn't even try, just says no match and tries to match with some knowledge... seems like something is bad with setup then?

nicky-ru added a commit to iotexproject/Eliza-IoTeX that referenced this issue Dec 10, 2024
nicky-ru added a commit to iotexproject/Eliza-IoTeX that referenced this issue Dec 10, 2024
@0xCardinalError
Copy link
Contributor

when I removed knowledge from trump file, then wallet works, somehow knowledge "trumps" actions

@0xCardinalError
Copy link
Contributor

From what I see there are many problems with the transfer code.

First, there is no processing of content in transfer.ts so it can get any parameters. Something like this is needed

        const transferContext = composeContext({
            state,
            template: transferTemplate,
        });

        const content = await generateObjectDEPRECATED({
            runtime,
            context: transferContext,
            modelClass: ModelClass.LARGE,
        });
        ````
        
Then the token in template is not set anywhere {{walletInfo}}

Then also as EVM is multichain, wallet itself is not setup to read context of message and wallet.ts is provider, so it should also first read message and set content and use the chain mentioned there to switch the chain to get balance of native token and or other tokens
        

@nicky-ru
Copy link
Contributor

hey @n00b21337! i see we're working on the same plugin, what do you think about the fix in the pr above^ #864

@0xCardinalError
Copy link
Contributor

hey @n00b21337! i see we're working on the same plugin, what do you think about the fix in the pr above^ #864

ohh I missed it, let me check. thnx for tip

@kaiqiangh
Copy link

Facing error when revoking swap_token action:

◎ LOGS
Creating Memory
0f28aa92-7237-02e0-b101-5173659aca17
Swapping 0.001 BNB to USDT. (SWAP_TOKENS)

["✓ Normalized action: swaptokens"]

["ℹ Executing handler for action: swap"]

Swap action handler called
["⛔ TypeError: Cannot read properties of undefined (reading 'default')"]

@kaiqiangh
Copy link

Facing error when revoking swap_token action:

◎ LOGS Creating Memory 0f28aa92-7237-02e0-b101-5173659aca17 Swapping 0.001 BNB to USDT. (SWAP_TOKENS)

["✓ Normalized action: swaptokens"]

["ℹ Executing handler for action: swap"]

Swap action handler called ["⛔ TypeError: Cannot read properties of undefined (reading 'default')"]

Part of character.json file:

{
"name": "Agent",
"clients": ["telegram"],
"modelProvider": "openai",
"settings": {
"secrets": {},
"voice": {
"model": "en_US-male-medium"
},
"chains": {
"evm": ["bsc"]
}
},
"plugins": ["@elizaos/plugin-evm"],
......
}

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

No branches or pull requests

5 participants