Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

User Profile API - WeaveHacks Benchmark

Mock API for testing OpenClaw cross-session memory and learning.

The Test

Session 1: Agent is told the API has strict rate limits (1 req/sec) and will ban if exceeded. Fetches 5 users successfully.

Session 2: Agent is asked to fetch 5 users again, but rate limit is NOT mentioned. Does it remember and avoid getting banned?

Rate Limit Rules

  • Limit: 1 request per second per session
  • Violation: If ANY request comes <1s after the previous one → INSTANT BAN
  • Ban = permanent (for that session ID, until manually reset)

Setup

Local Development

pip install -r requirements.txt
python app.py

Server runs on http://localhost:5000

Replit Deployment

  1. Create new Repl
  2. Import from GitHub: https://github.com/[YOUR_USERNAME]/UserProfileAPIWB
  3. Click "Run" (Replit auto-detects Flask)
  4. Your API will be at: https://[repl-name].[your-username].repl.co

API Endpoints

GET /users/<id>

Fetch user by ID (1-5 available).

Required Header:

X-Session-ID: your-session-identifier

Success Response (200):

{
  "id": 1,
  "name": "Alice Johnson",
  "email": "alice@example.com",
  "role": "Engineer",
  "_meta": {
    "session_id": "session-123",
    "request_count": 1,
    "timestamp": "2026-02-01T07:15:00Z"
  }
}

Rate Limit Exceeded (429 - BAN):

{
  "error": "Rate limit exceeded - ACCOUNT BANNED",
  "reason": "Requests must be at least 1.0s apart",
  "time_since_last_request": 0.342,
  "message": "This session is now permanently banned."
}

GET /status/<session_id>

Check session status.

Response:

{
  "session_id": "session-123",
  "banned": false,
  "request_count": 5,
  "last_request": 1738393700.123,
  "status": "active"
}

POST /reset/<session_id>

Reset a banned session (for testing).

Response:

{
  "message": "Session session-123 reset successfully",
  "previous_status": {
    "banned": true,
    "request_count": 3
  }
}

Testing

Quick Test (curl)

# Should succeed
curl -H "X-Session-ID: test1" http://localhost:5000/users/1

# Wait 1+ seconds, then:
curl -H "X-Session-ID: test1" http://localhost:5000/users/2

# Fire immediately (should BAN):
curl -H "X-Session-ID: test2" http://localhost:5000/users/1
curl -H "X-Session-ID: test2" http://localhost:5000/users/2

Check Status

curl http://localhost:5000/status/test2

Reset

curl -X POST http://localhost:5000/reset/test2

License

MIT

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages