insight-chat: code-review polish on the tool-gating PR
- search_messages now delegates to search_messages_with_contact(.., None) so the two methods share a single HTTP path. Drops the dead-code warning and the ~30-line duplication. - DailySummaryDao gains has_any_summaries (LIMIT 1 existence probe) used by current_gate_opts; the SELECT COUNT(*) get_total_summary_count added in the prior commit is removed (it had no other caller). - current_gate_opts doc comment corrected to describe what the probes actually do. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -144,10 +144,13 @@ impl InsightGenerator {
|
||||
}
|
||||
|
||||
/// Compute the per-call tool gate options by probing each backing
|
||||
/// table. Cheap (`SELECT 1 FROM <t> LIMIT 1` shape via the existing
|
||||
/// count methods); meant to be called once per chat turn / generation.
|
||||
/// `has_vision` is supplied by the caller because it depends on the
|
||||
/// model selected for this turn, not on persistent state.
|
||||
/// table for presence. `daily_summaries_present` uses a `LIMIT 1`
|
||||
/// existence probe; `calendar_present` and `location_history_present`
|
||||
/// use the existing `get_event_count` / `get_location_count`
|
||||
/// methods (small enough that a full `COUNT(*)` is fine). Meant to
|
||||
/// be called once per chat turn / generation. `has_vision` is
|
||||
/// supplied by the caller because it depends on the model selected
|
||||
/// for this turn, not on persistent state.
|
||||
pub fn current_gate_opts(&self, has_vision: bool) -> ToolGateOpts {
|
||||
let cx = opentelemetry::Context::new();
|
||||
let calendar_present = {
|
||||
@@ -169,9 +172,7 @@ impl InsightGenerator {
|
||||
.daily_summary_dao
|
||||
.lock()
|
||||
.expect("Unable to lock DailySummaryDao");
|
||||
dao.get_total_summary_count(&cx)
|
||||
.map(|n| n > 0)
|
||||
.unwrap_or(false)
|
||||
dao.has_any_summaries(&cx).unwrap_or(false)
|
||||
};
|
||||
ToolGateOpts {
|
||||
has_vision,
|
||||
|
||||
Reference in New Issue
Block a user