Skip to content

Commit 130f26e

Browse files
stonks-gitclaude
andcommitted
Fix empty query crash in context assembly + telegram offset
- context_assembly.py: pass attention_text to search_hybrid instead of empty string (pre-existing bug, crashed on first real message) - telegram_peripheral.py: fix drop_pending_updates offset calculation to prevent replaying old messages on startup Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent a5442e8 commit 130f26e

3 files changed

Lines changed: 13 additions & 7 deletions

File tree

src/context_assembly.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ async def assemble_context(
4343
cognitive_state_report: str,
4444
conversation: list[dict],
4545
total_budget: int = 131072,
46+
attention_text: str = "",
4647
) -> dict:
4748
"""Assemble the full context for an LLM call.
4849
@@ -94,6 +95,7 @@ async def assemble_context(
9495
if situational_budget > 0 and attention_embedding is not None:
9596
situational = await _get_situational_memories(
9697
memory_store, attention_embedding, situational_budget,
98+
query_text=attention_text,
9799
)
98100
for mem in situational:
99101
parts["situational"].append(
@@ -222,14 +224,13 @@ async def _get_top_identity_memories(memory_store, top_n: int) -> list[dict]:
222224

223225
async def _get_situational_memories(
224226
memory_store, attention_embedding: np.ndarray, budget: int,
227+
query_text: str = "",
225228
) -> list[dict]:
226229
"""Retrieve situationally relevant memories within token budget."""
227-
# Use hybrid search for retrieval
230+
if not query_text:
231+
return [] # Can't search without query text
228232
candidates = await memory_store.search_hybrid(
229-
# We need the query text, but we have the embedding.
230-
# For now, use search_similar which accepts embeddings via text.
231-
# This will be improved when retrieval pipeline is fully wired.
232-
query="", # placeholder — will use attention embedding directly later
233+
query=query_text,
233234
top_k=10,
234235
)
235236

src/loop.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,7 @@ async def cognitive_loop(config, layers, memory, shutdown_event, input_queue: as
441441
cognitive_state_report=cognitive_report,
442442
conversation=conversation,
443443
total_budget=131072,
444+
attention_text=winner.content,
444445
)
445446

446447
system_prompt = render_system_prompt(context)

src/telegram_peripheral.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,12 @@ async def run(self, shutdown_event: asyncio.Event):
6868
return
6969

7070
# Drop pending updates from before this session
71-
await self._api("getUpdates", {"offset": -1})
72-
self._offset = 0
71+
drop = await self._api("getUpdates", {"offset": -1})
72+
if drop:
73+
last_id = max(u.get("update_id", 0) for u in drop)
74+
self._offset = last_id + 1
75+
else:
76+
self._offset = 0
7377

7478
# Main polling loop
7579
while not shutdown_event.is_set():

0 commit comments

Comments
 (0)