[Bug] Portable memory pack fails for agent IDs containing hyphens

Open Beginner friendly
#3,161 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
76/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python, sqlite
Domain
backend, databases

Research direction

Read octop/api/common/memory_client.py and trace memory_namespace() into octop/api/routers/memory_portable.py, where the portable pack locates its source. Reproduce with a hyphenated agent ID and the SQLite backend. Done when packing finds the normalized tables and includes the agent's memory rows; the issue gives the successful repro result as 182 rows.

Written by the indexing model from the issue text.

Description

Description

Memory pack/adopt (and the dashboard "Migrate Memory" action) fails for any
agent whose agent_id contains a hyphen, e.g. problem-attack-expert.
The SQLite backend stores data under a normalized table prefix, but
memory_namespace() returns the un-normalized ID, so no source is found.

Environment
  • Octop site-packages build, octop-memory 1.0.5, SQLite memory backend
  • Agent renamed from a 6-letter ID to a hyphenated slug
Steps to reproduce
  1. Create/rename an agent to an ID containing - (e.g. problem-attack-expert).
  2. Ensure its memory.sqlite has raw_events, e.g. agent_problem_attack_expert_raw_events.
  3. Dashboard -> Migrate Memory -> Export, or
    POST /api/agents/problem-attack-expert/memory/portable/pack
Actual result

ValueError: nothing to migrate: namespace 'agent_problem-attack-expert'
has no raw_events data.

Expected result

A pack containing the agent's memories (182 rows / 132528 bytes in the repro case).

Root cause

octop/api/common/memory_client.py:memory_namespace() returns
f"{_MEMORY_NS_PREFIX}{agent_id}" with the hyphen intact. The SQLite backend
normalizes a namespace into a table prefix via
re.sub(r"[^a-z0-9_]", "_", ns.lower()), so the real tables are
agent_problem_attack_expert_*. octop/api/routers/memory_portable.py
uses the un-normalized name to locate a source, finds none, falls back to a
SourceInfo with the bad namespace, and pack() then reports "nothing to migrate".

Verification
  • ns agent_problem-attack-expert -> ValueError
  • ns agent_problem_attack_expert -> 182 rows / 132528 bytes, success
Suggested fix

Normalize inside memory_namespace():
return re.sub(r"[^a-z0-9_]", "", f"agent{agent_id}".lower())

Note: PR #3082 documents this normalization but does not touch
memory_client.py or memory_portable.py, so it does not cover this bug.

Dominant language
Python
Stars
12.5k
Forks
1.8k
Avg merge
1d 1h
Merged PRs (30d)
155

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from TencentCloud/Octop

All issues in TencentCloud/Octop

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.