agentdb_pattern_store_batch fails: BatchOperations.insertPatterns writes context/outcome columns the schema never creates
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 89
- Forks
- 15
- PR merge metrics
- No merged PRs in 30d
Description
Summary
On agentdb@3.0.0-alpha.18, the agentdb_pattern_store_batch MCP tool always fails with the generic error:
❌ Batch pattern storage failed: An error occurred while processing your request.
while sequential agentdb_pattern_store calls succeed against the same database.
Root cause
Schema drift between the batch writer and the canonical schema:
-
src/controllers/ReasoningBank.tscreatesreasoning_patternswith columnsid, ts, task_type, approach, success_rate, uses, avg_reward, tags, metadata— nocontext, nooutcome(dist:dist/src/controllers/ReasoningBank.jslines 65–75). -
src/optimizations/BatchOperations.tsinsertPatterns()prepares:INSERT INTO reasoning_patterns ( task_type, approach, context, success_rate, outcome, uses, tags, metadata ) VALUES (?, ?, ?, ?, ?, ?, ?, ?)(dist:
dist/src/optimizations/BatchOperations.jslines 117–121).
SQLite rejects the INSERT (table reasoning_patterns has no column named context), the handler's catch swallows the specific error, and the tool reports the generic message above.
Repro
npx agentdb@latest mcpwith a fresh or existing DB.- Call
agentdb_pattern_store_batchwith any single valid pattern (taskType,approach,successRate). - Fails.
agentdb_pattern_storewith the same payload succeeds.
Workaround
ALTER TABLE reasoning_patterns ADD COLUMN context TEXT;
ALTER TABLE reasoning_patterns ADD COLUMN outcome TEXT;
After the migration, batch insert works immediately (verified: 2 patterns in 24ms).
Suggested fix
Either add context/outcome to the canonical reasoning_patterns DDL (they seem intentional — insertPatterns embeds context in the embedding text), or drop them from the batch INSERT. Also consider surfacing the underlying SqliteError message in the batch handler's error response — the generic wrapper made this much harder to diagnose than it needed to be.
Related note
agentdb_init also fails on better-sqlite3 builds compiled with SQLITE_DQS=0: dist/src/mcp/agentdb-mcp-server.js line 891 uses WHERE type=\"table\" (double-quoted string literal). Single-quoting fixes it. Happy to split this into its own issue if preferred.
Environment
- agentdb 3.0.0-alpha.18 via
npx agentdb@latest mcp - macOS (darwin arm64), node from npx cache, better-sqlite3 bundled build
Contributor guide
No contributing guide indexed for this repository
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.
Research direction
Start by comparing the canonical schema in src/controllers/ReasoningBank.ts with insertPatterns() in src/optimizations/BatchOperations.ts, then reproduce the failure with agentdb_pattern_store_batch against a fresh database. Done means valid batch patterns insert successfully without a manual ALTER TABLE, while the sequential store still works; keep the unrelated agentdb_init quoting note separate.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- sqlite, typescript
- Domain
- database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 72/100