fix(worker): search_all_worker_traces 排除调用者自身的意图 trace
之前走 ActivityTraceSearch(nil) 会把 worker 自己这条意图的步骤也搜出来 (纯噪声,本就在其上下文里)。新增 ActivityTraceSearchExcluding(node_id<>x), 工具传 t.ownerNode:worker=自身意图→排除自己;planner/mainagent 不受影响。 Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
1 parent
db2e1f9a49
commit
9c1591ad8e
2 files changed
+29
-4
No files matched your search
@@ -615,6 +615,29 @@ AND (summary ILIKE $2 OR detail ILIKE $2) ORDER BY id LIMIT $3`, s.expID, like,
|
||||
return scanTrace(rows)
|
||||
}
|
||||
|
||||
// ActivityTraceSearchExcluding keyword-searches every node's steps in this
|
||||
// exploration EXCEPT one node's own (excludeNodeID) — so a worker's
|
||||
// search_all_worker_traces doesn't return its own in-progress trace (which is
|
||||
// already in its context). excludeNodeID<=0 → no exclusion (searches all nodes).
|
||||
func (s *ExplorationStore) ActivityTraceSearchExcluding(excludeNodeID int64, q string, limit int) ([]Activity, error) {
|
||||
if excludeNodeID <= 0 {
|
||||
return s.ActivityTraceSearch(nil, q, limit)
|
||||
}
|
||||
if limit <= 0 {
|
||||
limit = 100
|
||||
}
|
||||
like := "%" + q + "%"
|
||||
rows, err := s.db.Query(`SELECT `+traceCols+`
|
||||
FROM activity WHERE exploration_id=$1 AND node_id IS NOT NULL AND node_id <> $2
|
||||
AND kind NOT IN ('thinking','usage')
|
||||
AND (summary ILIKE $3 OR detail ILIKE $3) ORDER BY id LIMIT $4`, s.expID, excludeNodeID, like, limit)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
return scanTrace(rows)
|
||||
}
|
||||
|
||||
// ActivityByIDs loads full detail for specific step ids (the trace drill-down),
|
||||
// scoped to this exploration. thinking rows are skipped (never returned, even if
|
||||
// their id is asked for). Order is ascending id, not the input order.
|
||||
|
||||
Reference in new issue
Block a user