fix(proxy): satisfy LIT010 and LIT014 in the tool discovery buffer

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
devin-ai-integration[bot] 2026-10-23 20:58:17 +00:00
parent e78eab9d69
commit d642ada2f7
3 changed files with 5 additions and 4 deletions

View file

@ -9,6 +9,7 @@ import json
from collections.abc import Mapping, Sequence
from datetime import datetime
from functools import reduce
from itertools import chain
from typing import TYPE_CHECKING, Any, Final, Literal, TypeAlias, TypeVar, cast
from pydantic import TypeAdapter
@ -604,7 +605,7 @@ class RedisUpdateBuffer:
if not entries:
return ()
batches: Final = tuple(_TOOL_DISCOVERY_ITEMS.validate_json(entry) for entry in entries)
return aggregate_tool_discoveries(item for batch in batches for item in batch)
return aggregate_tool_discoveries(chain.from_iterable(batches))
@with_service_target(SPEND_QUEUE_TARGET)
async def store_spend_logs_in_redis(

View file

@ -26,8 +26,7 @@ def aggregate_tool_discoveries(items: Iterable[ToolDiscoveryQueueItem]) -> tuple
"""Collapse items to one per tool_name, summing call_count, in first-seen order."""
by_name: dict[str, ToolDiscoveryQueueItem] = {} # mutable-ok: single pass fold keyed by tool_name
for item in items:
tool_name = item.get("tool_name", "")
if not tool_name:
if not (tool_name := item.get("tool_name", "")):
continue
by_name[tool_name] = _merged(by_name.get(tool_name), item)
return tuple(by_name.values())

View file

@ -8,6 +8,7 @@ Admins use the management endpoints to read and update input_policy / output_pol
import uuid
from collections.abc import Mapping, Sequence
from datetime import datetime, timezone
from itertools import chain
from types import MappingProxyType
from typing import TYPE_CHECKING, Final, Protocol
@ -159,7 +160,7 @@ def build_tool_bulk_upsert(items: Sequence[ToolDiscoveryQueueItem]) -> tuple[str
' "last_used_at" = EXCLUDED."last_used_at",\n'
' "updated_at" = EXCLUDED."updated_at"'
)
return sql, tuple(value for item in items for value in _tool_row_params(item))
return sql, tuple(chain.from_iterable(map(_tool_row_params, items)))
async def batch_upsert_tools(