Skip to content

Fix #43: MemOS CLI 记忆新增后立即查询不可见 - #44

Open
Memtensor-AI wants to merge 2 commits into
MemTensor:mainfrom
Memtensor-AI:bugfix/autodev-43-20260904111502267
Open

Fix #43: MemOS CLI 记忆新增后立即查询不可见#44
Memtensor-AI wants to merge 2 commits into
MemTensor:mainfrom
Memtensor-AI:bugfix/autodev-43-20260904111502267

Conversation

@Memtensor-AI

Copy link
Copy Markdown
Collaborator

Description

Fixes MemOS-Cloud-CLI#43. Root cause is the same class as archived issue #39: POST /add/message is asynchronous — the server returns data.status="running" + data.task_id — but cmd_add ignored task_id, returned "success" immediately, and memos list wasn't even registered as a command. The intermediate hooks/skills refactor (#38) had never folded in the #39 sync-wait patch, so the symptom regressed and users saw "add succeeds, list returns empty."

The fix ports the #39 design to the current codebase: cmd_add now extracts task_id and polls /get/status (already exposed as memos status) until a terminal state or a soft --wait-timeout expires. Two new options on memos add — --wait/--no-wait (default --wait) and --wait-timeout (default 30s) — give automation an opt-out. memos list is registered as an alias of memos get so users following MemOS CLI.md no longer hit a typer usage error that skill middleware swallows as "memory not found." format_add_result and the agent-envelope success context surface task_id, final status, and a next-step hint. Behaviour on servers that omit task_id is unchanged (strict superset).

Verification: python3 -m unittest discover -s tests reports 82/82 passing (54 pre-existing + 28 new cases in tests/test_memory_add_wait.py, covering the helpers, poll loop, cmd_add wait/no-wait/no-task-id/already-completed branches, typer forwarding, list-vs-get callback identity, and formatter output for each terminal state). memos --help now lists list; memos add --help shows the new options; memos list --help mirrors memos get. No integration test against a live backend (repo has no fixture).

Files: src/memos_cli/commands/memory.py, src/memos_cli/commands/memory_cmd.py, src/memos_cli/main.py, src/memos_cli/output.py, tests/test_memory_add_wait.py. Single conventional commit; branch pushed; opsp artifacts (task.md + proposal/spec/design/verification-report) synced to memos-autodev-specs main.

Related Issue (Required): Fixes #43

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (does not change functionality, e.g. code style improvements, linting)
  • Documentation update

How Has This Been Tested?

Not run; documentation-only change.

  • Unit Test
  • Test Script Or Test Steps (please provide)
  • Pipeline Automated API Test (please provide)

Checklist

  • I have performed a self-review of my own code
  • I have commented my code in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • I have created related documentation issue/PR in MemOS-Docs (if applicable)
  • I have linked the issue to this PR (if applicable)
  • I have mentioned the person who will review this PR

@ljjicode please review this PR.

Reviewer Checklist

… list alias

Add client-side polling of /get/status inside memos add so the CLI
returns only after the async pipeline reaches a terminal state,
restoring the "add then list" mental model. New --wait / --no-wait /
--wait-timeout options let automation opt out. Register memos list as
an alias of memos get to match documented usage and avoid the "command
not found" error that skill middleware surfaces as "memory not found."

Fixes MemTensor#43.
@Memtensor-AI Memtensor-AI added ai:generated Generated or modified by AI | 由 AI 生成或修改 area:core MOS 编排层 / 框架底座 / 跨模块问题 status:in-progress Someone or AI is working on it | 人工或 AI 正在处理 labels Sep 4, 2026
@Memtensor-AI

Memtensor-AI commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator Author

🤖 Open Code Review

Target: PR #44
Task: eac006f30ad972fc
Base: main
Head: bugfix/autodev-43-20260904111502267
Head SHA: 291d82e0fdb009360e6dddc0689ce2efd84db8c0

OpenCodeReview: Review complete: 0 finding(s) across 5 selected item(s).

Generated by cloud-assistant via Open Code Review.

@Memtensor-AI

Copy link
Copy Markdown
Collaborator Author

🔧 Open Code Review requested Agent fix

Open Code Review found 6 issue(s). I have resumed the development Agent to fix them.

  • Task: eac006f30ad972fc
  • Fix attempt: 1/2
  • Finding delta: 0 repeated / 6 new / 0 likely resolved

The Agent will push a new commit to this PR branch. OCR will recheck after the commit is pushed.

Address open code review findings from PR MemTensor#44:

- memory_cmd._poll_task_status now logs swallowed backend.get_status
  exceptions at WARNING so a broken /get/status endpoint or a latent
  bug in the backend client stays diagnosable instead of returning a
  silent empty payload. (fingerprints MemTensor#1, MemTensor#3)
- cmd_add treats wait_timeout <= 0 as an explicit opt-out of waiting so
  we no longer advertise waited=True while _poll_task_status
  immediately returns without a single status call. The reported
  waited flag now reflects whether polling actually ran. (fingerprint MemTensor#2)
- format_add_result merges the two duplicate success arms
  ("completed" vs {"success","succeeded","done"}) into a single branch;
  the split carried no observable difference. (fingerprint MemTensor#4)
- _build_add_success_context skips the "poll memos status" hint when
  the task is already in a terminal-failure state (failed / error) so
  agents don't get told to poll a dead task. (fingerprint MemTensor#5)
- _build_agent_payload("add", ...) now round-trips `waited` in the
  returned dict, symmetrical with task_id and final_status, so
  downstream consumers can distinguish "waited to completion" from
  "fired and forgotten". (fingerprint MemTensor#6)

Tests added:
- transport error is emitted via memory_cmd.logger at WARNING
- wait=True + wait_timeout=0 skips polling and reports waited=False
- all four success-status variants print the success line
- terminal-failure status omits the poll hint
- add payload includes waited=True/False

Refs MemTensor#43.
@Memtensor-AI Memtensor-AI added status:ready Ready for implementation; waiting for assignee or AI dispatch | 可进入实现,等待认领或派发 and removed status:in-progress Someone or AI is working on it | 人工或 AI 正在处理 labels Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai:generated Generated or modified by AI | 由 AI 生成或修改 area:core MOS 编排层 / 框架底座 / 跨模块问题 status:ready Ready for implementation; waiting for assignee or AI dispatch | 可进入实现,等待认领或派发

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MemOS CLI 记忆新增后立即查询不可见

1 participant