agentx-python 0.8.18__py3-none-any.whl → 0.8.19__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.
agentx/tracing/tracer.py CHANGED
@@ -581,6 +581,14 @@ class _RetrievalRecorder:
581
581
  self.output: Any = None
582
582
 
583
583
 
584
+ class _MemoryOpRecorder:
585
+ """Handle yielded by ``Tracer.trace_memory()`` - set ``output`` (what was recalled or
586
+ stored) inside the block."""
587
+
588
+ def __init__(self) -> None:
589
+ self.output: Any = None
590
+
591
+
584
592
  class _ToolCallRecorder:
585
593
  """Handle yielded by ``Tracer.trace_tool_call()`` - set ``output`` inside the block.
586
594
  ``success``/``error`` may be set manually; an exception escaping the block sets them
@@ -832,6 +840,66 @@ class Tracer:
832
840
  span_kind="retrieval",
833
841
  )
834
842
 
843
+ def record_memory(
844
+ self,
845
+ name: str = "Memory",
846
+ *,
847
+ operation: Optional[str] = None,
848
+ query: Optional[str] = None,
849
+ output: Any = None,
850
+ duration_ms: Optional[float] = None,
851
+ start_time: Optional[float] = None,
852
+ end_time: Optional[float] = None,
853
+ ) -> None:
854
+ """
855
+ Manually record a long-term-memory operation (a Mem0/Zep/Letta-style recall or store)
856
+ as a ``span_kind="memory"`` child span of the active span. ``operation`` is free text -
857
+ conventionally ``"read"`` or ``"write"`` - carried in the span's metadata; the kind
858
+ itself stays one value so dashboards and scorers can select all memory activity at once.
859
+ Deliberately NOT a retrieval: retrieval spans feed the RAG judges' ``{context}``
860
+ (knowledge grounding), while memory is recalled state - see the engine's spanKind.ts.
861
+ """
862
+ active_span = self.current_span
863
+ if active_span is None:
864
+ return
865
+ active_span.child_span(
866
+ name,
867
+ start_time=start_time,
868
+ end_time=end_time,
869
+ duration_ms=duration_ms,
870
+ input=query,
871
+ output=output,
872
+ metadata={"kind": "memory", **({"operation": operation} if operation else {})},
873
+ span_kind="memory",
874
+ )
875
+
876
+ @contextmanager
877
+ def trace_memory(
878
+ self, name: str = "Memory", *, operation: Optional[str] = None, query: Optional[str] = None
879
+ ) -> Iterator["_MemoryOpRecorder"]:
880
+ """
881
+ Context manager that times a memory operation and records it via
882
+ :meth:`record_memory` on exit::
883
+
884
+ with tracer.trace_memory("user prefs", operation="read", query=user_id) as m:
885
+ m.output = memory.search(user_id, question)
886
+ """
887
+ start_t = time.time()
888
+ recorder = _MemoryOpRecorder()
889
+ try:
890
+ yield recorder
891
+ finally:
892
+ end_t = time.time()
893
+ self.record_memory(
894
+ name,
895
+ operation=operation,
896
+ query=query,
897
+ output=recorder.output,
898
+ duration_ms=(end_t - start_t) * 1000,
899
+ start_time=start_t,
900
+ end_time=end_t,
901
+ )
902
+
835
903
  @contextmanager
836
904
  def trace_retrieval(self, name: str = "Retrieval", *, query: Optional[str] = None) -> Iterator["_RetrievalRecorder"]:
837
905
  """
agentx/version.py CHANGED
@@ -1,7 +1,7 @@
1
- VERSION = "0.8.18"
1
+ VERSION = "0.8.19"
2
2
 
3
3
  # The AgentX-trace-eval release this SDK version is tested against - what `agentx-trace-eval`
4
4
  # installs and converges to (see agentx/cli.py). Bump together with VERSION when releasing, so
5
5
  # every published SDK names a known-good engine+dashboard pair. Users can override with
6
6
  # AGENTX_TRACE_EVAL_VERSION=<tag|latest>.
7
- ENGINE_VERSION = "v0.3.18"
7
+ ENGINE_VERSION = "v0.3.19"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: agentx-python
3
- Version: 0.8.18
3
+ Version: 0.8.19
4
4
  Summary: Official Python SDK for AgentX (https://www.agentx.so/)
5
5
  Home-page: https://github.com/AgentX-ai/AgentX-python
6
6
  Author: Robin Wang and AgentX Team
@@ -10,7 +10,7 @@ agentx/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
10
  agentx/testing.py,sha256=0shZEid_vhJgBegpO_loUq6APYDxQrUgD3jvcRdIDV8,7372
11
11
  agentx/traces.py,sha256=sz9gxutlDKNgf0fdCkyzKsGwK5eMAJuIEl3NIwGrsuo,2287
12
12
  agentx/util.py,sha256=lt2Kpg4Fj8whrSuAhLEahcPEIYRVpK9RCC5y9ShdTJs,703
13
- agentx/version.py,sha256=12ZEc4OJ-zU1rtsHoDBC5wqnwX7BmZ9OmiL3F4NWnMQ,366
13
+ agentx/version.py,sha256=uZFelTcDOUCZeQsTxaCj6X0keAwmJ6whvtr9_8pafg0,366
14
14
  agentx/evaluations/__init__.py,sha256=Erv7RGFlRxGTG4rVb2uHhCqLLEX_iAWKqkZKzK6CumE,262
15
15
  agentx/evaluations/_term.py,sha256=WFpiNzdgDBeJJ-Gg-6X7TwwxllobuE4OqFUTuDQvS3Y,2529
16
16
  agentx/evaluations/client.py,sha256=f5GqsiuqknE-ENUYocBcXgV6OGMKdzmlsm76takJbwU,33112
@@ -65,10 +65,10 @@ agentx/tracing/ci_types.py,sha256=zFVcZGvc1qbVDdOlEPQ1i5R6terqJHxCzFF4ZjouxxI,14
65
65
  agentx/tracing/eval_scope.py,sha256=ElMbPxpqpQBVuaUnHNlw9RIQu71oyOpd0yR55bDH8eI,2144
66
66
  agentx/tracing/framework_detect.py,sha256=uV4O7Th-4_2UkdooAyaWCOIA0jwLJbblFQ_ucFDjeJM,2638
67
67
  agentx/tracing/ingest_client.py,sha256=spnm6bV3NXGuj2w7HwdKiJdKDJWRUFmSP3jl3rcGqkQ,18202
68
- agentx/tracing/tracer.py,sha256=TxY6zG6hbM81jpfrqP4imaEvoyy_hnJVUSTnoAVHMG0,56240
69
- agentx_python-0.8.18.dist-info/licenses/LICENSE,sha256=gZVsM-nLsE8vlaY6NXXsVoo6IlCClxkToAWmhgT3y_s,10762
70
- agentx_python-0.8.18.dist-info/METADATA,sha256=P0yCj9IwWgJrN6c_YcDBWj5YZeJCFaBkz_CNv1mJ2p4,22117
71
- agentx_python-0.8.18.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
72
- agentx_python-0.8.18.dist-info/entry_points.txt,sha256=rQqF1JTY3T1yfviBU1r8PU-5mBdfOk6P4bZ1L4BskIM,172
73
- agentx_python-0.8.18.dist-info/top_level.txt,sha256=s-q-HB9Gb_QdrZNacSeQyF_c25gQooMy7DlxzgLOHPk,7
74
- agentx_python-0.8.18.dist-info/RECORD,,
68
+ agentx/tracing/tracer.py,sha256=VQbHT1qhkdOZZy5_SEBZaivl2qKjGPruAj8SqBbMcNY,58727
69
+ agentx_python-0.8.19.dist-info/licenses/LICENSE,sha256=gZVsM-nLsE8vlaY6NXXsVoo6IlCClxkToAWmhgT3y_s,10762
70
+ agentx_python-0.8.19.dist-info/METADATA,sha256=U2phHPdoDEXuwj0uBze7zHyq5HPr1aOE7sUL8hOg7_Y,22117
71
+ agentx_python-0.8.19.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
72
+ agentx_python-0.8.19.dist-info/entry_points.txt,sha256=rQqF1JTY3T1yfviBU1r8PU-5mBdfOk6P4bZ1L4BskIM,172
73
+ agentx_python-0.8.19.dist-info/top_level.txt,sha256=s-q-HB9Gb_QdrZNacSeQyF_c25gQooMy7DlxzgLOHPk,7
74
+ agentx_python-0.8.19.dist-info/RECORD,,