Fix XMTP agent getting started guide Step 4 #569
Closed
+52
−10
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What changed? Why?
This PR fixes critical issues in Step 4 of the XMTP agent getting started guide that prevented users from successfully creating and running their first agent.
While following the tutorial, I encountered multiple blocking errors that made it impossible to complete the guide.
Issue 1: Deprecated
getTestUrlimport causing SyntaxErrorProblem:
The documentation shows this import:
Error encountered:
Root cause:
The
getTestUrlexport has been removed or deprecated from the@xmtp/agent-sdkpackage.Solution:
Removed the deprecated import and simplified the start event logging to only show the agent address.
Issue 2: Missing environment variable loading causing
XMTP_WALLET_KEYerrorProblem:
When running the agent code from the documentation, it immediately failed with:
Root cause:
The
.envfile existed with correct values, but the code wasn’t loading environment variables before callingAgent.createFromEnv().Solution:
Added
import "dotenv/config";at the top of the code to load environment variables before the agent initializes.Issue 3: Unclear file location for agent code
Problem:
Step 4 showed the agent code but never explicitly stated where to create the file. I was left guessing whether to:
Solution:
Added explicit instructions to create
index.tsin the project root using:Issue 4: Incorrect run command
Problem:
The documentation mentioned
npm run dev, but this runs the default example (xmtp-gm) frompackage.json, not the developer's newly created agent.Solution:
Updated instructions to use:
which directly runs the dev's agent file.
Issue 5: Adding testing instructions
Problem:
After fixing the above issues, the agent runs successfully but only outputs:
There were no clickable links or instructions on how to interact with the agent.
Solution:
Added comprehensive testing instructions:
**Added explanatory comments to code **
Added detailed inline comments explaining:
dotenv/configis neededcreateFromEnvdoesAdded
import "dotenv/config".touch index.tsin root).npx tsx --watch index.ts).devvsproduction).Removed
getTestUrlimport and usage.Notes to Reviewers
These changes address real, blocking errors that prevented me from completing the tutorial.
Every change is based on actual errors encountered during testing:
The updated code has been tested end-to-end and works successfully.
I also spun up the documentation site locally to verify formatting and that the Tip callouts render correctly.
How has it been tested?
Started from a fresh clone of the
xmtp-agent-examplesrepositoryVerified agent started without errors
Sent test messages and confirmed agent responded with
"Hello from my XMTP Agent! 👋"Spun up documentation site locally