anomalyco / anomalyco/opencode
Tool execute() receives operation=undefined for enum arg when value is large
Open
@rekram1-node is already working on this.
Since Jul 25, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- Avg merge
- 7h 2m
- Merged PRs (30d)
- 384
Description
Environment
- opencode version: 1.18.4
- Platform: linux
Bug
When calling a tool with an enum argument (operation) alongside a large value, the tool's execute() receives operation: undefined instead of the provided value (e.g. "write").
Reproduction
Tool definition (TypeScript, enum on operation):
args: {
operation: tool.schema
.enum(["write", "read", "forget", "list", "search", "stats"])
.describe("..."),
key: tool.schema.string(),
value: tool.schema.string(),
tags: tool.schema.string(),
}
Call (first time — second with short value worked):
{
"operation": "write",
"key": "session.save.2026-07-26",
"value": "CRM 2026-07-26: Session complete. Final commit 96bca81. Single table cards (id + 15 optional fields), 4 sub-agent tools (search_cards, save_card, delete_card, list_cards), main chat with handle_client_request (1 tool). EntityDatabase replaced ClientDatabase. FastFlow works with 4 tool schemas. client_database.h/cpp removed.",
"tags": "session,save,crm,cards"
}
Result
Error from argparse (Python script called by tool):
ERROR: memory.py: error: argument --operation: invalid choice: 'undefined' (choose from write, read, forget, list, search, stats, rag_store, rag_find)
The CLI received --operation=undefined meaning args.operation was undefined at template literal interpolation time.
Expected
args.operation should retain its provided value "write" regardless of other argument sizes.
Notes
- Second call with a short value (56 chars) worked correctly.
- This suggests the large "value" argument causes a serialization/deserialization issue in opencode's argument passing that corrupts or drops the enum argument.
- Workaround in the tool (guard + escape) applied locally, but the root cause is in opencode.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.