Skip to content

Commit a69add0

Browse files
authored
feat: restructure API URLs for better clarity and consistency
2 parents 8542276 + ae6916f commit a69add0

File tree

9 files changed

+73
-72
lines changed

9 files changed

+73
-72
lines changed

CLAUDE.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,10 +191,10 @@ ENABLE_NER=true
191191
## API Interfaces
192192

193193
### REST API (Port 8000)
194-
- Session management (`/sessions/`)
195-
- Working memory operations (`/sessions/{id}/memory`)
196-
- Long-term memory search (`/memories/search`)
197-
- Memory hydration (`/memories/hydrate`)
194+
- Session management (`/v1/working-memory/`)
195+
- Working memory operations (`/v1/working-memory/{id}`)
196+
- Long-term memory search (`/v1/long-term-memory/search`)
197+
- Memory hydration (`/v1/memory/prompt`)
198198

199199
### MCP Server (Port 9000)
200200
- `create_long_term_memories` - Store persistent memories

agent_memory_server/api.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ async def _summarize_working_memory(
136136
return updated_memory
137137

138138

139-
@router.get("/sessions/", response_model=SessionListResponse)
139+
@router.get("/v1/working-memory/", response_model=SessionListResponse)
140140
async def list_sessions(
141141
options: GetSessionsQuery = Depends(),
142142
current_user: UserInfo = Depends(get_current_user),
@@ -165,7 +165,7 @@ async def list_sessions(
165165
)
166166

167167

168-
@router.get("/sessions/{session_id}/memory", response_model=WorkingMemoryResponse)
168+
@router.get("/v1/working-memory/{session_id}", response_model=WorkingMemoryResponse)
169169
async def get_session_memory(
170170
session_id: str,
171171
namespace: str | None = None,
@@ -219,7 +219,7 @@ async def get_session_memory(
219219
return working_mem
220220

221221

222-
@router.put("/sessions/{session_id}/memory", response_model=WorkingMemoryResponse)
222+
@router.put("/v1/working-memory/{session_id}", response_model=WorkingMemoryResponse)
223223
async def put_session_memory(
224224
session_id: str,
225225
memory: WorkingMemory,
@@ -296,7 +296,7 @@ async def put_session_memory(
296296
return updated_memory
297297

298298

299-
@router.delete("/sessions/{session_id}/memory", response_model=AckResponse)
299+
@router.delete("/v1/working-memory/{session_id}", response_model=AckResponse)
300300
async def delete_session_memory(
301301
session_id: str,
302302
namespace: str | None = None,
@@ -326,7 +326,7 @@ async def delete_session_memory(
326326
return AckResponse(status="ok")
327327

328328

329-
@router.post("/long-term-memory", response_model=AckResponse)
329+
@router.post("/v1/long-term-memory/", response_model=AckResponse)
330330
async def create_long_term_memory(
331331
payload: CreateMemoryRecordRequest,
332332
background_tasks=Depends(get_background_tasks),
@@ -364,7 +364,7 @@ async def create_long_term_memory(
364364
return AckResponse(status="ok")
365365

366366

367-
@router.post("/long-term-memory/search", response_model=MemoryRecordResultsResponse)
367+
@router.post("/v1/long-term-memory/search", response_model=MemoryRecordResultsResponse)
368368
async def search_long_term_memory(
369369
payload: SearchRequest,
370370
current_user: UserInfo = Depends(get_current_user),
@@ -401,7 +401,7 @@ async def search_long_term_memory(
401401
return await long_term_memory.search_long_term_memories(**kwargs)
402402

403403

404-
@router.post("/memory/search", response_model=MemoryRecordResultsResponse)
404+
@router.post("/v1/memory/search", response_model=MemoryRecordResultsResponse)
405405
async def search_memory(
406406
payload: SearchRequest,
407407
current_user: UserInfo = Depends(get_current_user),
@@ -448,7 +448,7 @@ async def search_memory(
448448
return await long_term_memory.search_memories(**kwargs)
449449

450450

451-
@router.post("/memory-prompt", response_model=MemoryPromptResponse)
451+
@router.post("/v1/memory/prompt", response_model=MemoryPromptResponse)
452452
async def memory_prompt(
453453
params: MemoryPromptRequest,
454454
current_user: UserInfo = Depends(get_current_user),

agent_memory_server/client/api.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ async def health_check(self) -> HealthCheckResponse:
116116
Returns:
117117
HealthCheckResponse with current server timestamp
118118
"""
119-
response = await self._client.get("/health")
119+
response = await self._client.get("/v1/health")
120120
response.raise_for_status()
121121
return HealthCheckResponse(**response.json())
122122

@@ -143,7 +143,7 @@ async def list_sessions(
143143
elif self.config.default_namespace is not None:
144144
params["namespace"] = self.config.default_namespace
145145

146-
response = await self._client.get("/sessions/", params=params)
146+
response = await self._client.get("/v1/working-memory/", params=params)
147147
response.raise_for_status()
148148
return SessionListResponse(**response.json())
149149

@@ -188,7 +188,7 @@ async def get_session_memory(
188188
params["context_window_max"] = context_window_max
189189

190190
response = await self._client.get(
191-
f"/sessions/{session_id}/memory", params=params
191+
f"/v1/working-memory/{session_id}", params=params
192192
)
193193
response.raise_for_status()
194194
return WorkingMemoryResponse(**response.json())
@@ -211,7 +211,7 @@ async def put_session_memory(
211211
memory.namespace = self.config.default_namespace
212212

213213
response = await self._client.put(
214-
f"/sessions/{session_id}/memory",
214+
f"/v1/working-memory/{session_id}",
215215
json=memory.model_dump(exclude_none=True, mode="json"),
216216
)
217217
response.raise_for_status()
@@ -237,7 +237,7 @@ async def delete_session_memory(
237237
params["namespace"] = self.config.default_namespace
238238

239239
response = await self._client.delete(
240-
f"/sessions/{session_id}/memory", params=params
240+
f"/v1/working-memory/{session_id}", params=params
241241
)
242242
response.raise_for_status()
243243
return AckResponse(**response.json())
@@ -391,7 +391,8 @@ async def create_long_term_memory(
391391

392392
payload = CreateMemoryRecordRequest(memories=memories)
393393
response = await self._client.post(
394-
"/long-term-memory", json=payload.model_dump(exclude_none=True, mode="json")
394+
"/v1/long-term-memory/",
395+
json=payload.model_dump(exclude_none=True, mode="json"),
395396
)
396397
response.raise_for_status()
397398
return AckResponse(**response.json())
@@ -471,7 +472,7 @@ async def search_long_term_memory(
471472
)
472473

473474
response = await self._client.post(
474-
"/long-term-memory/search",
475+
"/v1/long-term-memory/search",
475476
json=payload.model_dump(exclude_none=True, mode="json"),
476477
)
477478
response.raise_for_status()
@@ -566,7 +567,7 @@ async def search_memories(
566567
)
567568

568569
response = await self._client.post(
569-
"/memory/search",
570+
"/v1/memory/search",
570571
json=payload.model_dump(exclude_none=True, mode="json"),
571572
)
572573
response.raise_for_status()
@@ -638,7 +639,7 @@ async def memory_prompt(
638639

639640
# Make the API call
640641
response = await self._client.post(
641-
"/memory-prompt", json=payload.model_dump(exclude_none=True, mode="json")
642+
"/v1/memory/prompt", json=payload.model_dump(exclude_none=True, mode="json")
642643
)
643644
response.raise_for_status()
644645
data = response.json()
@@ -761,7 +762,7 @@ async def hydrate_memory_prompt(
761762

762763
# Make the API call
763764
response = await self._client.post(
764-
"/memory-prompt", json=payload.model_dump(exclude_none=True, mode="json")
765+
"/v1/memory/prompt", json=payload.model_dump(exclude_none=True, mode="json")
765766
)
766767
response.raise_for_status()
767768
data = response.json()

agent_memory_server/healthcheck.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
router = APIRouter()
99

1010

11-
@router.get("/health", response_model=HealthCheckResponse)
11+
@router.get("/v1/health", response_model=HealthCheckResponse)
1212
async def get_health():
1313
"""
1414
Health check endpoint

docs/api.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@
22

33
The following endpoints are available:
44

5-
- **GET /health**
5+
- **GET /v1/health**
66
A simple health check endpoint returning the current server time.
77
Example Response:
88

99
```json
1010
{ "now": 1616173200 }
1111
```
1212

13-
- **GET /sessions/**
13+
- **GET /v1/working-memory/**
1414
Retrieves a paginated list of session IDs.
1515
_Query Parameters:_
1616

1717
- `limit` (int): Number of sessions per page (default: 10)
1818
- `offset` (int): Number of sessions to skip (default: 0)
1919
- `namespace` (string, optional): Filter sessions by namespace.
2020

21-
- **GET /sessions/{session_id}/memory**
21+
- **GET /v1/working-memory/{session_id}**
2222
Retrieves working memory for a session, including messages, structured memories,
2323
context, and metadata.
2424
_Query Parameters:_
@@ -28,7 +28,7 @@ The following endpoints are available:
2828
- `model_name` (string, optional): The client's LLM model name to determine appropriate context window size
2929
- `context_window_max` (int, optional): Direct specification of max context window tokens (overrides model_name)
3030

31-
- **PUT /sessions/{session_id}/memory**
31+
- **PUT /v1/working-memory/{session_id}**
3232
Sets working memory for a session, replacing any existing memory.
3333
Automatically summarizes conversations that exceed the window size.
3434
_Request Body Example:_
@@ -52,10 +52,10 @@ The following endpoints are available:
5252
}
5353
```
5454

55-
- **DELETE /sessions/{session_id}/memory**
55+
- **DELETE /v1/working-memory/{session_id}**
5656
Deletes all working memory (messages, context, structured memories, metadata) for a session.
5757

58-
- **POST /long-term-memory**
58+
- **POST /v1/long-term-memory/**
5959
Creates long-term memories directly, bypassing working memory.
6060
_Request Body Example:_
6161

@@ -73,7 +73,7 @@ The following endpoints are available:
7373
}
7474
```
7575

76-
- **POST /long-term-memory/search**
76+
- **POST /v1/long-term-memory/search**
7777
Performs vector search on long-term memories with advanced filtering options.
7878
_Request Body Example:_
7979

@@ -92,7 +92,7 @@ The following endpoints are available:
9292
}
9393
```
9494

95-
- **POST /memory-prompt**
95+
- **POST /v1/memory/prompt**
9696
Generates prompts enriched with relevant memory context from both working
9797
memory and long-term memory. Useful for retrieving context before answering questions.
9898
_Request Body Example:_

docs/authentication.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ OAUTH2_AUDIENCE=your-application-id
6464
# Make authenticated API request
6565
curl -H "Authorization: Bearer YOUR_JWT_TOKEN" \
6666
-H "Content-Type: application/json" \
67-
http://localhost:8000/sessions/
67+
http://localhost:8000/v1/working-memory/
6868

6969
# Python example
7070
import httpx
@@ -74,7 +74,7 @@ headers = {
7474
"Content-Type": "application/json"
7575
}
7676

77-
response = httpx.get("http://localhost:8000/sessions/", headers=headers)
77+
response = httpx.get("http://localhost:8000/v1/working-memory/", headers=headers)
7878
```
7979

8080
### Development Mode (Local Testing)
@@ -85,7 +85,7 @@ export DISABLE_AUTH=true
8585

8686
# Now you can make requests without tokens
8787
curl -H "Content-Type: application/json" \
88-
http://localhost:8000/sessions/
88+
http://localhost:8000/v1/working-memory/
8989
```
9090

9191
## Token Requirements

docs/memory-types.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,13 @@ Working memory contains:
8686

8787
```http
8888
# Get working memory for a session
89-
GET /sessions/{session_id}/memory?namespace=demo&window_size=50
89+
GET /v1/working-memory/{session_id}?namespace=demo&window_size=50
9090
9191
# Set working memory (replaces existing)
92-
PUT /sessions/{session_id}/memory
92+
PUT /v1/working-memory/{session_id}
9393
9494
# Delete working memory
95-
DELETE /sessions/{session_id}/memory?namespace=demo
95+
DELETE /v1/working-memory/{session_id}?namespace=demo
9696
```
9797

9898
### Automatic Promotion
@@ -200,13 +200,13 @@ Long-term memory supports three types of memories:
200200

201201
```http
202202
# Create long-term memories
203-
POST /long-term-memory
203+
POST /v1/long-term-memory/
204204
205205
# Search long-term memories only
206-
POST /long-term-memory/search
206+
POST /v1/long-term-memory/search
207207
208208
# Search across all memory types
209-
POST /memory/search
209+
POST /v1/memory/search
210210
```
211211

212212
### Search Capabilities
@@ -295,7 +295,7 @@ results = await search_memories(
295295

296296
## Memory Prompt Integration
297297

298-
The memory system integrates with AI prompts through the `/memory-prompt` endpoint:
298+
The memory system integrates with AI prompts through the `/v1/memory/prompt` endpoint:
299299

300300
```python
301301
# Get memory-enriched prompt

manual_oauth_qa/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -162,14 +162,14 @@ echo "Access Token: $TOKEN"
162162
# Test sessions endpoint
163163
curl -H "Authorization: Bearer $TOKEN" \
164164
-H "Content-Type: application/json" \
165-
http://localhost:8000/sessions/
165+
http://localhost:8000/v1/working-memory/
166166

167167
# Test memory prompt
168168
curl -X POST \
169169
-H "Authorization: Bearer $TOKEN" \
170170
-H "Content-Type: application/json" \
171171
-d '{"query": "What is the capital of France?", "session_id": "test-session"}' \
172-
http://localhost:8000/memory-prompt
172+
http://localhost:8000/v1/memory/prompt
173173

174174
# Test long-term memory creation
175175
curl -X POST \
@@ -184,27 +184,27 @@ curl -X POST \
184184
}
185185
]
186186
}' \
187-
http://localhost:8000/long-term-memory
187+
http://localhost:8000/v1/long-term-memory/
188188

189189
# Test memory search
190190
curl -X POST \
191191
-H "Authorization: Bearer $TOKEN" \
192192
-H "Content-Type: application/json" \
193193
-d '{"text": "Auth0 test", "limit": 5}' \
194-
http://localhost:8000/long-term-memory/search
194+
http://localhost:8000/v1/long-term-memory/search
195195
```
196196

197197
#### Test Authentication Rejection
198198

199199
```bash
200200
# Test without token (should return 401)
201201
curl -H "Content-Type: application/json" \
202-
http://localhost:8000/sessions/
202+
http://localhost:8000/v1/working-memory/
203203

204204
# Test with invalid token (should return 401)
205205
curl -H "Authorization: Bearer invalid.jwt.token" \
206206
-H "Content-Type: application/json" \
207-
http://localhost:8000/sessions/
207+
http://localhost:8000/v1/working-memory/
208208
```
209209

210210
### Method 3: Using Python Requests
@@ -234,7 +234,7 @@ headers = {
234234
"Content-Type": "application/json"
235235
}
236236

237-
response = requests.get("http://localhost:8000/sessions/", headers=headers)
237+
response = requests.get("http://localhost:8000/v1/working-memory/", headers=headers)
238238
print(f"Status: {response.status_code}")
239239
print(f"Response: {response.json()}")
240240
```

0 commit comments

Comments
 (0)