Skip to content

Conversation

@wamimi
Copy link
Contributor

@wamimi wamimi commented Oct 26, 2025

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 getTestUrl import causing SyntaxError

Problem:
The documentation shows this import:

import { Agent, getTestUrl } from "@xmtp/agent-sdk";

Error encountered:

SyntaxError: The requested module '@xmtp/agent-sdk' does not provide an export named 'getTestUrl'

Root cause:
The getTestUrl export has been removed or deprecated from the @xmtp/agent-sdk package.

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_KEY error

Problem:
When running the agent code from the documentation, it immediately failed with:

AgentError: XMTP_WALLET_KEY env is not in hex (0x) format.
    at Agent.createFromEnv (/node_modules/@xmtp/agent-sdk/src/core/Agent.ts:190:13)

Root cause:
The .env file existed with correct values, but the code wasn’t loading environment variables before calling Agent.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:

  • Create it in the examples folder
  • Create it in the root
  • Replace an existing file

Solution:
Added explicit instructions to create index.ts in the project root using:

touch index.ts

Issue 4: Incorrect run command

Problem:
The documentation mentioned npm run dev, but this runs the default example (xmtp-gm) from package.json, not the developer's newly created agent.

Solution:
Updated instructions to use:

npx tsx --watch index.ts

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:

Agent is online at address: 0x4a86dfa0ad31801256dd5f8bdf95b3ea5bbe2ba9

There were no clickable links or instructions on how to interact with the agent.

Solution:
Added comprehensive testing instructions:

  1. Copy the agent address from terminal
  2. Go to xmtp.chat
  3. Connect wallet
  4. Switch to Dev environment
  5. Start new conversation with the agent address
  6. Send a message and verify the response

**Added explanatory comments to code **

Added detailed inline comments explaining:

  • Why dotenv/config is needed
  • What createFromEnv does
  • How the event listeners work
  • What each parameter means

Added

  • 💡 Tip callout explaining the critical importance of import "dotenv/config".
  • Clear file creation instructions (touch index.ts in root).
  • Correct run command (npx tsx --watch index.ts).
  • Step-by-step testing instructions for xmtp.chat.
  • Tip about environment matching (dev vs production).
  • Detailed Inline code comments for more clarity.

Removed

  • Deprecated getTestUrl import and usage.
  • Confusing sections about the examples folder workflow.

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-examples repository
Verified agent started without errors
Sent test messages and confirmed agent responded with
"Hello from my XMTP Agent! 👋"
Spun up documentation site locally

- Fix deprecated getTestUrl import that caused SyntaxError
- Add critical dotenv/config import to resolve XMTP_WALLET_KEY error
- Clarify file location: create index.ts in project root
- Update run command to use npx tsx --watch index.ts
- Add detailed testing instructions for xmtp.chat
- Include code comments explaining each section
@cb-heimdall
Copy link
Collaborator

cb-heimdall commented Oct 26, 2025

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 0
Sum 1

@humanagent
Copy link
Contributor

humanagent commented Oct 27, 2025

@wamimi Thanks for the update! we have a pending PR a well, i think it's about to merge #435

@wamimi
Copy link
Contributor Author

wamimi commented Oct 31, 2025

@wamimi Thanks for the update! we have a pending PR a well, i think it's about to merge #435

Thanks for letting me know! I see that PR #435 has been merged. I've opened a new PR (#610) that builds on top of those changes and addresses some additional flow issues I discovered while testing the guide. I'll close this PR now since #435 is merged. Looking forward to your feedback on #610!

@wamimi wamimi closed this Oct 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants