dasein-core 0.2.16__py3-none-any.whl → 0.2.17__py3-none-any.whl

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.
dasein/api.py CHANGED
@@ -3044,11 +3044,9 @@ Follow these rules when planning your actions."""
3044
3044
  print(f"Query: {query}")
3045
3045
  print("-" * 50)
3046
3046
 
3047
- # Clear trace before each run (except the first one)
3047
+ # Reset callback handler state before each run (except the first one)
3048
+ # Note: reset_run_state() already clears trace, function calls, guards, and timers
3048
3049
  if i > 0:
3049
- from .capture import clear_trace
3050
- clear_trace()
3051
- # Reset callback handler state (function calls, injection guard)
3052
3050
  if hasattr(self, '_callback_handler') and hasattr(self._callback_handler, 'reset_run_state'):
3053
3051
  self._callback_handler.reset_run_state()
3054
3052
 
@@ -3088,11 +3086,9 @@ Follow these rules when planning your actions."""
3088
3086
  print(f"Query: {query}")
3089
3087
  print("-" * 50)
3090
3088
 
3091
- # Clear trace before each run (except the first one)
3089
+ # Reset callback handler state before each run (except the first one)
3090
+ # Note: reset_run_state() already clears trace, function calls, guards, and timers
3092
3091
  if i > 0:
3093
- from .capture import clear_trace
3094
- clear_trace()
3095
- # Reset callback handler state (function calls, injection guard)
3096
3092
  if hasattr(self, '_callback_handler') and hasattr(self._callback_handler, 'reset_run_state'):
3097
3093
  self._callback_handler.reset_run_state()
3098
3094
 
dasein/capture.py CHANGED
@@ -379,6 +379,7 @@ class DaseinCallbackHandler(BaseCallbackHandler):
379
379
  self._compiled_tools_metadata = [] # Store extracted tools
380
380
  self._pipecleaner_embedding_model = None # Cache embedding model for this run
381
381
  self._current_tool_name = None # Track currently executing tool for hotpath deduplication
382
+ self._last_reset_ts = None # Debounce guard for reset_run_state()
382
383
 
383
384
  # Generate stable run_id for corpus deduplication
384
385
  import uuid
@@ -397,6 +398,24 @@ class DaseinCallbackHandler(BaseCallbackHandler):
397
398
 
398
399
  def reset_run_state(self):
399
400
  """Reset state that should be cleared between runs."""
401
+ # Debounce: suppress duplicate rapid invocations (e.g., from multiple callers in same tick)
402
+ try:
403
+ from time import monotonic
404
+ now = monotonic()
405
+ if getattr(self, '_last_reset_ts', None) is not None and (now - self._last_reset_ts) < 0.05:
406
+ # Too soon since last reset; skip
407
+ return
408
+ self._last_reset_ts = now
409
+ except Exception:
410
+ pass
411
+ # Optional debug: print caller stack to trace root cause of unexpected resets
412
+ try:
413
+ import os, traceback
414
+ if os.getenv("DASEIN_DEBUG_RESET", "0") == "1":
415
+ stack_excerpt = ''.join(traceback.format_stack(limit=8))
416
+ self._vprint("[DASEIN][CALLBACK] reset_run_state() caller stack (set DASEIN_DEBUG_RESET=0 to disable):\n" + stack_excerpt, True)
417
+ except Exception:
418
+ pass
400
419
  self._function_calls_made = {}
401
420
  self._injection_guard = set()
402
421
  self._trace = [] # Clear instance trace
@@ -1796,7 +1815,7 @@ EXECUTION STATE (functions called so far in this run):
1796
1815
 
1797
1816
  """
1798
1817
 
1799
- combined_injection = f""" SYSTEM OVERRIDE — PLANNING TURN ONLY
1818
+ combined_injection = f""" SYSTEM OVERRIDE
1800
1819
  These rules OVERRIDE all defaults. You MUST enforce them exactly or the task FAILS.
1801
1820
 
1802
1821
  Tags: AVOID (absolute ban), SKIP (force bypass), FIX (mandatory params), PREFER (ranked choice), HINT (optional).
@@ -2147,9 +2166,17 @@ def clear_trace() -> None:
2147
2166
  # Try to clear traces in active CognateProxy instances
2148
2167
  try:
2149
2168
  import gc
2169
+ seen_handlers = set()
2150
2170
  for obj in gc.get_objects():
2151
- if hasattr(obj, '_callback_handler') and hasattr(obj._callback_handler, 'reset_run_state'):
2152
- obj._callback_handler.reset_run_state()
2171
+ if hasattr(obj, '_callback_handler'):
2172
+ handler = getattr(obj, '_callback_handler', None)
2173
+ if handler is None or not hasattr(handler, 'reset_run_state'):
2174
+ continue
2175
+ handler_id = id(handler)
2176
+ if handler_id in seen_handlers:
2177
+ continue
2178
+ seen_handlers.add(handler_id)
2179
+ handler.reset_run_state()
2153
2180
  except Exception:
2154
2181
  pass # Ignore if not available
2155
2182
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dasein-core
3
- Version: 0.2.16
3
+ Version: 0.2.17
4
4
  Summary: Universal memory for agentic AI. Attach a brain to any LangChain/LangGraph agent in a single line.
5
5
  Author-email: Dasein Team <support@dasein.ai>
6
6
  License: MIT
@@ -1,7 +1,7 @@
1
1
  dasein/__init__.py,sha256=RY0lhaaWB6yJ_5YMRmaHDvQ0eFbc0BGbYNe5OVyxzYE,2316
2
2
  dasein/advice_format.py,sha256=5-h4J24L_B2Y9dlmyDuIYtmPCWOGAYoinBEXqpcNg2s,5386
3
- dasein/api.py,sha256=BAvF-uCZo2-rUUYLKJKcI2dF5iL0H6UF5c5QLZXYmOs,260956
4
- dasein/capture.py,sha256=LdbgiayFe7e6w_OpVGmifOjbFAbb65NaXoJTlAu3G0Q,110952
3
+ dasein/api.py,sha256=s4ncBuHVBkWsoITIiPjHddKFH8rX6p4z3dXJ3evflwU,260856
4
+ dasein/capture.py,sha256=3Gy_XBpHWPgXd7Ov48QBza6jcdtxGqWvyI8_gX2feUs,112198
5
5
  dasein/config.py,sha256=lXO8JG4RXbodn3gT5yEnuB0VRwWdrRVwhX3Rm06IZmU,1957
6
6
  dasein/events.py,sha256=mG-lnOvQoZUhXbrPSjrG4RME6ywUcbSZ04PscoJ15GI,12896
7
7
  dasein/extractors.py,sha256=fUFBVH9u2x4cJaM-8Zw4qiIpBF2LvjcdYkMvoXQUpL8,3986
@@ -45,7 +45,7 @@ dasein/services/post_run_client.py,sha256=UjK3eqf7oWGSuWkKe0vQmeMS0yUUOhYFD4-SZ7
45
45
  dasein/services/pre_run_client.py,sha256=tXmz_PQaSfq0xwypiWUAqNkXOmREZ6EwXLC4OM89J-A,4317
46
46
  dasein/services/service_adapter.py,sha256=YHk41lR3PXh8WTmxOzzwKf6hwPYGqIdApI92vQKlkAY,7350
47
47
  dasein/services/service_config.py,sha256=8_4tpV4mZvfaOc5_yyHbOyL4rYsPHzkLTEY1rtYgLs8,1629
48
- dasein_core-0.2.16.dist-info/licenses/LICENSE,sha256=7FHjIFEKl_3hSc3tGUVEWmufC_3oi8rh_2zVuL7jMKs,1091
48
+ dasein_core-0.2.17.dist-info/licenses/LICENSE,sha256=7FHjIFEKl_3hSc3tGUVEWmufC_3oi8rh_2zVuL7jMKs,1091
49
49
  dasein/models/en_core_web_sm/en_core_web_sm-3.7.1.dist-info/LICENSE,sha256=OTPBdpebaLxtC8yQLH1sEw8dEn9Hbxe6XNuo2Zz9ABI,1056
50
50
  dasein/models/en_core_web_sm/en_core_web_sm-3.7.1.dist-info/LICENSES_SOURCES,sha256=INnfrNIVESJR8VNB7dGkex-Yvzk6IS8Q8ZT_3H7pipA,2347
51
51
  dasein/models/en_core_web_sm/en_core_web_sm-3.7.1.dist-info/METADATA,sha256=-vGqRxa_M2RwKtLjBhc4JlBQdJ3k7CwOnseT_ReYcic,2958
@@ -53,7 +53,7 @@ dasein/models/en_core_web_sm/en_core_web_sm-3.7.1.dist-info/RECORD,sha256=dDb6U7
53
53
  dasein/models/en_core_web_sm/en_core_web_sm-3.7.1.dist-info/WHEEL,sha256=Xo9-1PvkuimrydujYJAjF7pCkriuXBpUPEjma1nZyJ0,92
54
54
  dasein/models/en_core_web_sm/en_core_web_sm-3.7.1.dist-info/entry_points.txt,sha256=OkWs-KxPJtDdpvIFCVXzDC9ECtejhPxv7pP3Tgk2cNg,47
55
55
  dasein/models/en_core_web_sm/en_core_web_sm-3.7.1.dist-info/top_level.txt,sha256=56OIuRbEuhr12HsM9XpCMnTtHRMgNC5Hje4Xeo8wF2c,15
56
- dasein_core-0.2.16.dist-info/METADATA,sha256=3HJxudOsEDk1fqjqvtGhM13eM51xL6GZuOMaK4EhMTg,10330
57
- dasein_core-0.2.16.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
58
- dasein_core-0.2.16.dist-info/top_level.txt,sha256=6yYY9kltjvvPsg9K6KyMKRtzEr5qM7sHXN7VzmrDtp0,7
59
- dasein_core-0.2.16.dist-info/RECORD,,
56
+ dasein_core-0.2.17.dist-info/METADATA,sha256=SExqKyN2OUZBrnzTyZk7w2iISvRTfTX2a5LD-cIEO-c,10330
57
+ dasein_core-0.2.17.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
58
+ dasein_core-0.2.17.dist-info/top_level.txt,sha256=6yYY9kltjvvPsg9K6KyMKRtzEr5qM7sHXN7VzmrDtp0,7
59
+ dasein_core-0.2.17.dist-info/RECORD,,