@misterhuydo/sentinel 1.1.8 → 1.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.cairn/session.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"message": "Auto-checkpoint at 2026-03-23T09:
|
|
3
|
-
"checkpoint_at": "2026-03-23T09:
|
|
2
|
+
"message": "Auto-checkpoint at 2026-03-23T09:20:28.044Z",
|
|
3
|
+
"checkpoint_at": "2026-03-23T09:20:28.045Z",
|
|
4
4
|
"active_files": [],
|
|
5
5
|
"notes": [],
|
|
6
6
|
"mtime_snapshot": {}
|
package/package.json
CHANGED
|
@@ -187,9 +187,9 @@ Session context — critical rules:
|
|
|
187
187
|
- When handling a new request, call the tools fresh. Do not assume any prior tool result is still current or that any prior step "counts" toward the current task.
|
|
188
188
|
- The only exception: if the user explicitly asks about something from the history ("what did you find earlier?"), you may reference it — but note it is from a prior session.
|
|
189
189
|
|
|
190
|
-
Avoid redundant tool calls:
|
|
191
|
-
- If a broad search (e.g. search_logs with no source filter) already returned results
|
|
192
|
-
- If a tool call fails
|
|
190
|
+
Avoid redundant tool calls (within a single response only — always run tools fresh for new requests):
|
|
191
|
+
- If a broad search (e.g. search_logs with no source filter) already returned results in THIS response, do NOT repeat the same search with a source filter to "refine" — use what you already fetched.
|
|
192
|
+
- If a tool call fails in THIS response, do NOT retry the entire search from scratch. Continue with what succeeded and note the failure.
|
|
193
193
|
- One pass per task: gather all needed data in a single round of tool calls, then produce the final answer.
|
|
194
194
|
|
|
195
195
|
Issue identification — before calling create_issue:
|
|
@@ -367,31 +367,61 @@ async def _dispatch(event: dict, client, cfg_loader, store) -> None:
|
|
|
367
367
|
|
|
368
368
|
_MAX_HISTORY_TURNS = 20 # keep last 20 exchanges (~40 messages) to stay well within context limits
|
|
369
369
|
|
|
370
|
+
|
|
371
|
+
def _strip_tool_turns(history: list) -> list:
|
|
372
|
+
"""
|
|
373
|
+
Remove any message that consists entirely of tool_use or tool_result blocks.
|
|
374
|
+
Keeps only plain text exchanges so loaded prior history doesn't contain stale
|
|
375
|
+
search results that the model might treat as already-done work.
|
|
376
|
+
"""
|
|
377
|
+
result = []
|
|
378
|
+
for msg in history:
|
|
379
|
+
content = msg.get("content", "")
|
|
380
|
+
# Plain string content — always keep
|
|
381
|
+
if isinstance(content, str):
|
|
382
|
+
result.append(msg)
|
|
383
|
+
continue
|
|
384
|
+
# List content — keep only if it has at least one text block
|
|
385
|
+
if isinstance(content, list):
|
|
386
|
+
has_text = any(
|
|
387
|
+
isinstance(b, dict) and b.get("type") == "text" and b.get("text", "").strip()
|
|
388
|
+
for b in content
|
|
389
|
+
)
|
|
390
|
+
if has_text:
|
|
391
|
+
# Keep only the text blocks, drop tool_use/tool_result
|
|
392
|
+
text_blocks = [b for b in content if isinstance(b, dict) and b.get("type") == "text"]
|
|
393
|
+
result.append({**msg, "content": text_blocks})
|
|
394
|
+
return result
|
|
395
|
+
|
|
370
396
|
async def _run_turn(session: _Session, message: str, client, cfg_loader, store, attachments: list | None = None, is_admin: bool = False) -> None:
|
|
371
397
|
channel = session.channel
|
|
372
398
|
|
|
373
399
|
# Load persisted history from DB on the first turn of a new session.
|
|
374
|
-
# - _clean_history strips orphaned tool_use turns from
|
|
375
|
-
# -
|
|
376
|
-
#
|
|
377
|
-
#
|
|
400
|
+
# - _clean_history strips orphaned tool_use turns from previous crashed sessions.
|
|
401
|
+
# - Strip all tool_use / tool_result blocks from prior history — only keep conversational
|
|
402
|
+
# text. Stale search results in prior history cause the model to skip re-running tools
|
|
403
|
+
# for new requests ("I already searched that"), which produces wrong/empty answers.
|
|
404
|
+
# - Trim to last 6 text exchanges (12 messages) to limit context bleed.
|
|
405
|
+
# - Inject a session boundary marker so the model clearly separates old from new.
|
|
378
406
|
if not session.history_loaded:
|
|
379
407
|
loaded = _clean_history(store.load_conversation(session.user_id))
|
|
380
408
|
if loaded:
|
|
381
|
-
|
|
409
|
+
text_only = _strip_tool_turns(loaded)
|
|
382
410
|
_PRIOR_TURNS = 6
|
|
383
|
-
trimmed =
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
411
|
+
trimmed = text_only[-(_PRIOR_TURNS * 2):]
|
|
412
|
+
if trimmed:
|
|
413
|
+
session.history = [
|
|
414
|
+
{
|
|
415
|
+
"role": "user",
|
|
416
|
+
"content": "[system: new session started — the following is prior conversation context only, no tool calls needed]",
|
|
417
|
+
},
|
|
418
|
+
{
|
|
419
|
+
"role": "assistant",
|
|
420
|
+
"content": [{"type": "text", "text": "Understood. Starting fresh — prior context is for reference only."}],
|
|
421
|
+
},
|
|
422
|
+
] + trimmed
|
|
423
|
+
else:
|
|
424
|
+
session.history = []
|
|
395
425
|
else:
|
|
396
426
|
session.history = []
|
|
397
427
|
session.history_loaded = True
|