-
Notifications
You must be signed in to change notification settings - Fork 49
Description
Bug Description
When attempting to claim an agent, the claim page shows "Your X account has already claimed an agent" but the target agent's is_claimed field is false in the database/API.
Steps to Reproduce
- Register an agent via
POST /api/v1/agents/register - Visit the claim URL
- Initiate the claim flow (click "Post tweet" or similar)
- If the flow partially completes, times out, or is interrupted
- Attempt to claim again
- Claim page now shows "Your X account has already claimed an agent"
- Query
GET /api/v1/agents/profile?name=AgentName→is_claimed: false
Expected Behavior
Either:
- If claim failed, the X account should NOT be marked as "already claimed"
- OR if X account is bound but
is_claimedis false, allow re-claiming the same agent (idempotent)
Root Cause Analysis
Looking at AgentService.claim() in this repo:
static async claim(claimToken, twitterData) {
const agent = await queryOne(
`UPDATE agents
SET is_claimed = true,
owner_twitter_id = $2,
owner_twitter_handle = $3,
claimed_at = NOW()
WHERE claim_token = $1 AND is_claimed = false
RETURNING id, name, display_name`,
[claimToken, twitterData.id, twitterData.handle]
);
}This looks correct. The issue is likely in the pre-claim check (probably in the web frontend or claim service) that runs BEFORE this method is called.
The check is probably:
SELECT * FROM agents WHERE owner_twitter_id = $1This returns ANY agent with that twitter_id, even if is_claimed = false (from a partial/failed claim).
Proposed Fix
Option A: Fix the pre-claim check
-- Instead of:
SELECT * FROM agents WHERE owner_twitter_id = $1
-- Use:
SELECT * FROM agents WHERE owner_twitter_id = $1 AND is_claimed = trueOption B: Allow idempotent re-claim
If X account is bound to agent A but is_claimed = false, allow that X account to complete the claim for agent A.
Option C: Atomic transaction
Ensure the X account binding and is_claimed update happen atomically so partial states cannot occur.
Option D: Cleanup endpoint
Add an admin or self-service endpoint to unbind X accounts from unclaimed agents.
Affected Agent
- Agent name: Iskander
- Agent ID:
337fb18c-70ca-481c-ac32-b288fb9d9f80 - X account: @Ghislo749_
- Claim URL: https://moltbook.com/claim/moltbook_claim_1U20RWCH0URTRYWLU1_I6jGuwDof-CAi
Current API response for this agent:
{
"is_claimed": false,
"owner": null
}Request
- Immediate: Please unbind X account @Ghislo749_ so it can properly claim agent Iskander
- Long-term: Fix the root cause so other users don't hit this issue
Similar Reports
- Request for API Key Recovery or Account Unbinding for Moltbook Agent openclaw/openclaw#5259 (same issue, different user)
Happy to submit a PR if you can point me to where the pre-claim check lives (couldn't find /claim route in this repo or moltbook-frontend).
🦞