실제로 사용된 budget 확인
응답은 used_items와 used_tokens를 보고하므로 정말 작은 응답인지 잘린 응답인지 구분할 수 있습니다.
recall_context({ query: "recent decisions", max_items: 6, max_tokens: 1200 })공개 MCP 도구
recall_context
목적
구조화된 item과 token-budgeted context text가 포함된 제한된 multi-memory context pack을 읽으며 아무것도 변경하지 않습니다.
사용 시점
- 세션 사이에서 작업, task 및 agent context를 계속하는 데 필요한 내용을 복원합니다.
- 명시적인 item 및 token budget 안에서 prompt 구성을 위한 관련 memory 여러 개를 모읍니다.
- 빠른 단일 결과만으로 충분하지 않은 session/task 시작 시 사용합니다.
사용하지 않을 시점
- 빠르고 유연한 단일 lookup에는 사용하지 않습니다. recall을 사용합니다.
- 엄격하고 targeted한 match만 허용해야 할 때 사용하지 않습니다. search_memory를 사용합니다.
- 범위가 제한되지 않은 history dump를 요청하지 않습니다. max_items와 max_tokens는 safety 및 context-quality limit입니다.
- REST API는 public MCP tool보다 더 넓은 field set을 허용합니다. scope, bucket, team 및 provenance filter는 /docs/api/memory를 참고합니다.
필수 스코프
- memory:read가 필요하며 scope, bucket, team 및 agent boundary는 server가 계속 적용합니다.
매개변수
| 이름 | 타입 | 설명 |
|---|---|---|
query | string · 필수 | context pack을 구성할 대상 자연어 query입니다. |
max_items | integer · 기본값: 8 | pack에 포함할 최대 memory 수입니다 (1-50). |
max_tokens | integer · 기본값: 1500 | render된 context의 최대 token 길이입니다 (1-12000). |
반환 스키마
Public MCP profile은 structured object가 아니라 text를 반환합니다. '### XMemo Context' heading과 'Items: <n>' line으로 시작하고, 결과가 삭제되거나 짧아진 경우 'Budget: ...' line을 추가한 다음, 각 item을 literal form 'Reference: <id> | Type: <type> | Location: <path>'의 한 줄로 표시하며, 마지막으로 bounded context body 앞에 'Context:' label을 둡니다. 일치하는 결과가 없으면 'No matching XMemo memory was found.'라고 표시합니다. reference는 opaque identifier로 처리합니다. Non-public profile은 structured pack (version, retrieval_plan, budget, items, context_text)을 반환할 수 있습니다.
예제
recall_context({
query: "recent decisions on the memory-os project",
max_items: 6,
max_tokens: 1200
})오류
- 401/403: 요청에 memory:read가 없거나 해당되는 경우 temporary-memory read capability가 없습니다.
- 422: max_items, max_tokens 또는 명시적인 limit이 지원되는 budget/candidate 범위를 벗어났습니다.
- Validation failure: query 또는 optional filter 중 하나의 형식이 잘못되었습니다.
관련 도구
- recall — 빠른 단일 answer에는 가벼운 best-effort 경로를 선택합니다.
- search_memory — weak result가 안전하지 않을 때 strict matching을 선택합니다.
- remember — capture policy가 승인한 새 영구 context를 저장합니다.
출처: SDK workflow 도우미