-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Worker API: /api/search/observations and /api/search/sessions ignore project parameter #1539
Description
Problem
The worker HTTP endpoints /api/search/observations and /api/search/sessions accept a project query parameter but ignore it completely. Queries always return results from all projects regardless of the project filter.
# Returns results from all projects even though project=project-a
curl "http://127.0.0.1:37777/api/search/observations?query=test&project=project-a"Root Cause
In src/services/worker/SearchManager.ts, the searchObservations() method (line ~889) destructures the project from params but never uses it:
async searchObservations(args: any): Promise<any> {
const normalized = this.normalizeParams(args);
const { query, ...options } = normalized;
// options.project exists but is never passed to queryChroma or hydration
const chromaResults = await this.queryChroma(query, 100); // no project filter
// ...
results = this.sessionStore.getObservationsByIds(recentIds, { orderBy: 'date_desc', limit }); // no project filter
}Same issue in searchSessions() (line ~946).
Note: The main search() method (line ~126), used by the MCP tool, correctly handles project filtering — it builds a Chroma where clause with the project and passes it through. Only searchObservations() and searchSessions() are affected.
Expected Behavior
When project is passed as a query parameter, results should be scoped to that project only — both in the Chroma vector query and in the SQLite hydration.
Proposed Fix
- Pass
options.projectas a Chromawherefilter inqueryChroma()calls - Pass
options.projecttogetObservationsByIds()/getSessionSummariesByIds()during hydration
This mirrors the pattern already used in the main search() method.
Impact
This bug breaks project-scoped search for:
- OpenClaw plugin search commands which call these endpoints with a project filter
- Any direct HTTP API consumers filtering by project
- The MCP
searchtool is not affected (it uses the mainsearch()method which handles project correctly)