Skip to content

Commit c090f40

Browse files
committed
fix: add unbound guard and fix return types on query methods
- query_tasks/query_pending_alarms raise RuntimeError if toolkit not bound - Return type corrected from dict[str, str] to dict[str, Any]
1 parent a1cf500 commit c090f40

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

src/hive/tools/alarms/toolkit.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import platform
88
from datetime import UTC, datetime, timedelta
99
from pathlib import Path
10-
from typing import TYPE_CHECKING
10+
from typing import TYPE_CHECKING, Any
1111
from uuid import uuid4
1212

1313
from hive.tools.base import Toolkit, tool
@@ -83,12 +83,14 @@ def instructions(self) -> str:
8383
"Specify hours, minutes, and/or seconds from now."
8484
)
8585

86-
async def query_pending_alarms(self) -> list[dict[str, str]]:
86+
async def query_pending_alarms(self) -> list[dict[str, Any]]:
8787
"""Query pending alarms for the bound agent. For host application use."""
88+
if not self._agent_id:
89+
raise RuntimeError("AlarmToolkit is not bound to an agent yet.")
8890
await self._ensure_init()
8991
return await self._store.list_pending_alarms(self._agent_id)
9092

91-
async def query_all_pending_alarms(self) -> list[dict[str, str]]:
93+
async def query_all_pending_alarms(self) -> list[dict[str, Any]]:
9294
"""Query pending alarms across all agents. For host application use."""
9395
await self._ensure_init()
9496
import aiosqlite

src/hive/tools/tasks/toolkit.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from __future__ import annotations
44

55
from pathlib import Path
6-
from typing import TYPE_CHECKING
6+
from typing import TYPE_CHECKING, Any
77
from uuid import uuid4
88

99
from hive.tools.base import Toolkit, tool
@@ -51,12 +51,14 @@ def instructions(self) -> str:
5151
"tasks, mark tasks as done, or delete them."
5252
)
5353

54-
async def query_tasks(self, status: str = "pending") -> list[dict[str, str]]:
54+
async def query_tasks(self, status: str = "pending") -> list[dict[str, Any]]:
5555
"""Query tasks for the bound agent. For host application use, not an agent tool."""
56+
if not self._agent_id:
57+
raise RuntimeError("TaskToolkit is not bound to an agent yet.")
5658
await self._ensure_init()
5759
return await self._store.list_tasks(self._agent_id, status)
5860

59-
async def query_all_tasks(self, status: str = "pending") -> list[dict[str, str]]:
61+
async def query_all_tasks(self, status: str = "pending") -> list[dict[str, Any]]:
6062
"""Query tasks across all agents. For host application use, not an agent tool."""
6163
await self._ensure_init()
6264
import aiosqlite

0 commit comments

Comments
 (0)