Short description
The ctx_memory tool definition visible to the LLM does not match the source code definition, causing frequent calling failures and infinite retry loops (especially with models like GLM 5.2).
What happened?
Description
The ctx_memory tool definition visible to the LLM does not match the source code definition, causing frequent calling failures and infinite retry loops (especially with models like GLM 5.2).
Environment
- Magic Context version: 0.32.0 (confirmed issue also present in v0.33.0 source via src/tools/ctx-memory/tools.ts)
- OpenCode: latest
Root Cause: 3 discrepancies between source and LLM-facing definition
1. Action enum mismatch
- Source
constants.ts: "Supported actions: write, delete, list, update, merge, archive" (6 actions)
- LLM sees:
enum: ["write", "archive", "update", "merge", "list"] (5 actions — delete missing, archive incorrectly renamed)
- If LLM calls
action="archive", the backend handler expects action="delete" → fails
2. Missing id parameter (critical)
- Source
tools.ts defines BOTH id: number and ids: number[]:
id → used for delete/update/archive actions
ids → used only for merge
- LLM sees only
ids: number[] (described as "required for update/archive/merge")
- LLM passes
ids: [42] for update → backend checks args.id (undefined) → "Error: 'id' is required"
3. Incomplete category description
- Source: "required for write, optional filter for list, optional override for merge"
- LLM: "required for write; optional merge override" (missing "filter for list")
Impact
- Any operation other than
write and list is guaranteed to fail
- GLM 5.2 entered an infinite retry loop (repeatedly calling with wrong params), wasting tokens
- Other frontier models also retry with slightly different params, getting the same error
Likely Cause
The opencode tool definition serialization layer appears to be merging id and ids parameters and remapping delete → archive. The source code in src/tools/ctx-memory/tools.ts defines both parameters correctly.
Steps to Reproduce
- Ask any LLM to update or delete an existing memory
- LLM calls
ctx_memory(action="update", ids=[42], content="new content")
- Backend returns "Error: 'id' is required"
- LLM retries with different params, same error
Diagnostics
Plugin version
0.32.0
OpenCode version
1.18.5
Platform
windows 64
Client
OpenCode TUI (CLI)
Log output (optional)
Short description
The
ctx_memorytool definition visible to the LLM does not match the source code definition, causing frequent calling failures and infinite retry loops (especially with models like GLM 5.2).What happened?
Description
The
ctx_memorytool definition visible to the LLM does not match the source code definition, causing frequent calling failures and infinite retry loops (especially with models like GLM 5.2).Environment
Root Cause: 3 discrepancies between source and LLM-facing definition
1. Action enum mismatch
constants.ts: "Supported actions: write, delete, list, update, merge, archive" (6 actions)enum: ["write", "archive", "update", "merge", "list"](5 actions —deletemissing,archiveincorrectly renamed)action="archive", the backend handler expectsaction="delete"→ fails2. Missing
idparameter (critical)tools.tsdefines BOTHid: numberandids: number[]:id→ used for delete/update/archive actionsids→ used only for mergeids: number[](described as "required for update/archive/merge")ids: [42]for update → backend checksargs.id(undefined) →"Error: 'id' is required"3. Incomplete category description
Impact
writeandlistis guaranteed to failLikely Cause
The opencode tool definition serialization layer appears to be merging
idandidsparameters and remappingdelete→archive. The source code insrc/tools/ctx-memory/tools.tsdefines both parameters correctly.Steps to Reproduce
ctx_memory(action="update", ids=[42], content="new content")Diagnostics
Plugin version
0.32.0
OpenCode version
1.18.5
Platform
windows 64
Client
OpenCode TUI (CLI)
Log output (optional)