2026-06-07 16:42:41 +08:00
|
|
|
# Obelisk Pitfalls
|
|
|
|
|
|
2026-06-07 20:31:31 +08:00
|
|
|
Use this after a query error, suspicious empty result, over-large output, or
|
|
|
|
|
unclear helper row shape. For query design, read `retrieval-semantics.md` first.
|
2026-06-07 16:42:41 +08:00
|
|
|
|
2026-06-07 20:31:31 +08:00
|
|
|
## Missing Columns And Wrong Aliases
|
2026-06-07 16:42:41 +08:00
|
|
|
|
2026-06-07 20:31:31 +08:00
|
|
|
Common wrong guesses:
|
2026-06-07 16:42:41 +08:00
|
|
|
|
2026-06-07 20:31:31 +08:00
|
|
|
- Summaries: use `source` and `content`; do not use `summary_type` or `text`.
|
|
|
|
|
- Tool call name: use `tool_calls.name`. `tool_name` is only an alias in `SELECT tc.name AS tool_name`; `tc.tool_name` is not a column.
|
|
|
|
|
- Tool call timestamps: `tool_calls` has no timestamp. Join `messages m ON m.uuid = tc.message_uuid`.
|
|
|
|
|
- Tool result timestamps: `tool_results` has no timestamp. Join `messages m ON m.uuid = tr.message_uuid`.
|
|
|
|
|
- Workflow agent message counts: `workflowTree()` returns `messageCount` for agents.
|
2026-06-07 16:42:41 +08:00
|
|
|
|
2026-06-07 20:31:31 +08:00
|
|
|
When uncertain, inspect a tiny sample instead of guessing:
|
2026-06-07 16:42:41 +08:00
|
|
|
|
|
|
|
|
```js
|
2026-06-07 20:31:31 +08:00
|
|
|
const rows = summaries({ limit: 1 });
|
|
|
|
|
return rows.length ? Object.keys(rows[0]) : [];
|
2026-06-07 16:42:41 +08:00
|
|
|
```
|
|
|
|
|
|
2026-06-07 20:31:31 +08:00
|
|
|
## FTS5 Syntax Errors
|
2026-06-07 16:42:41 +08:00
|
|
|
|
2026-06-07 20:31:31 +08:00
|
|
|
`search(text)` uses raw FTS5 `MATCH`. Hyphenated terms and punctuation can be
|
|
|
|
|
parsed as syntax.
|
2026-06-07 16:42:41 +08:00
|
|
|
|
|
|
|
|
```js
|
2026-06-07 20:31:31 +08:00
|
|
|
// tokenized phrase for FTS
|
2026-06-07 16:42:41 +08:00
|
|
|
search('"workflow script"', { limit: 10 })
|
|
|
|
|
```
|
|
|
|
|
|
2026-06-07 20:31:31 +08:00
|
|
|
For literal punctuation, use SQL `LIKE` under the same scope:
|
2026-06-07 16:42:41 +08:00
|
|
|
|
|
|
|
|
```js
|
|
|
|
|
sql(`
|
2026-06-07 20:31:31 +08:00
|
|
|
SELECT m.uuid, s.id AS session_id, s.title, substr(m.text,1,180) AS snippet
|
2026-06-07 16:42:41 +08:00
|
|
|
FROM messages m
|
|
|
|
|
JOIN sessions s ON s.id = m.session_id
|
|
|
|
|
WHERE s.project LIKE ?
|
|
|
|
|
AND m.text LIKE ?
|
2026-08-04 11:33:01 -04:00
|
|
|
AND COALESCE(m.visibility, 'visible') = 'visible'
|
2026-06-07 16:42:41 +08:00
|
|
|
ORDER BY m.timestamp DESC
|
|
|
|
|
LIMIT 10
|
|
|
|
|
`, '%quiet-zero%', '%workflow-script%')
|
|
|
|
|
```
|
|
|
|
|
|
2026-06-07 20:31:31 +08:00
|
|
|
## Over-Large Runtime JSON
|
2026-06-07 16:42:41 +08:00
|
|
|
|
2026-06-07 20:31:31 +08:00
|
|
|
If runtime stdout is large, fix the query instead of reading it in chunks.
|
2026-06-07 16:42:41 +08:00
|
|
|
|
2026-06-07 20:31:31 +08:00
|
|
|
- Lower `LIMIT`.
|
|
|
|
|
- Shorten snippets to 160-240 chars.
|
|
|
|
|
- Group in SQL/JS and return counts plus sparse examples.
|
|
|
|
|
- For `fileHistory()`, filter to `Edit`/`Write` before projecting evidence.
|
|
|
|
|
- For `workflowTree()`, omit `script`, `result_json`, and full agent messages unless explicitly requested.
|
|
|
|
|
- Use `raw(uuid, { offset, limit })` only after identifying one specific message UUID.
|
2026-06-07 16:42:41 +08:00
|
|
|
|
2026-06-07 20:31:31 +08:00
|
|
|
## Empty Results
|
2026-06-07 16:42:41 +08:00
|
|
|
|
2026-06-07 20:31:31 +08:00
|
|
|
An empty array can be the correct answer for exact scopes or sentinels.
|
2026-06-07 16:42:41 +08:00
|
|
|
|
2026-06-07 20:31:31 +08:00
|
|
|
When the user asks for a scoped project/file/session or exact term:
|
2026-06-07 16:42:41 +08:00
|
|
|
|
2026-06-07 20:31:31 +08:00
|
|
|
1. run the scoped query;
|
|
|
|
|
2. return `[]` or compact counts;
|
|
|
|
|
3. say no matching prior result was found;
|
|
|
|
|
4. do not call `recent()`, all-project `summaries()`, or `thread()` as fallback unless the user asks.
|
2026-06-07 16:42:41 +08:00
|
|
|
|
2026-06-07 20:31:31 +08:00
|
|
|
## Counting From Snippets
|
|
|
|
|
|
|
|
|
|
If the user asks "how many", "counts", "top N", or "group by", compute it in
|
|
|
|
|
SQL or in the query script. Do not infer counts from visible snippets.
|
2026-06-07 16:42:41 +08:00
|
|
|
|
|
|
|
|
```js
|
|
|
|
|
sql(`
|
2026-06-07 20:31:31 +08:00
|
|
|
SELECT tc.name AS tool_name, COUNT(*) AS n
|
2026-06-07 16:42:41 +08:00
|
|
|
FROM tool_results tr
|
|
|
|
|
JOIN tool_calls tc ON tc.id = tr.tool_use_id
|
|
|
|
|
WHERE tr.is_error = 1
|
|
|
|
|
GROUP BY tc.name
|
|
|
|
|
ORDER BY n DESC
|
|
|
|
|
LIMIT 10
|
|
|
|
|
`)
|
|
|
|
|
```
|