hebbrix 2.11.0__tar.gz → 2.12.0__tar.gz
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.
- {hebbrix-2.11.0 → hebbrix-2.12.0}/CHANGELOG.md +5 -0
- {hebbrix-2.11.0/hebbrix.egg-info → hebbrix-2.12.0}/PKG-INFO +11 -5
- {hebbrix-2.11.0 → hebbrix-2.12.0}/README.md +10 -4
- {hebbrix-2.11.0 → hebbrix-2.12.0}/hebbrix/__init__.py +3 -1
- {hebbrix-2.11.0 → hebbrix-2.12.0}/hebbrix/answers.py +68 -17
- {hebbrix-2.11.0 → hebbrix-2.12.0}/hebbrix/client.py +1 -1
- {hebbrix-2.11.0 → hebbrix-2.12.0}/hebbrix/models.py +26 -1
- {hebbrix-2.11.0 → hebbrix-2.12.0}/hebbrix/sync_client.py +1 -1
- {hebbrix-2.11.0 → hebbrix-2.12.0/hebbrix.egg-info}/PKG-INFO +11 -5
- {hebbrix-2.11.0 → hebbrix-2.12.0}/hebbrix.egg-info/SOURCES.txt +1 -0
- {hebbrix-2.11.0 → hebbrix-2.12.0}/pyproject.toml +1 -1
- hebbrix-2.12.0/tests/test_answer_values.py +280 -0
- {hebbrix-2.11.0 → hebbrix-2.12.0}/tests/test_customer_developer_experience.py +1 -1
- {hebbrix-2.11.0 → hebbrix-2.12.0}/LICENSE +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.0}/MANIFEST.in +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.0}/contracts/openapi-routes.json +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.0}/docs/native-experience-operations.md +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.0}/examples/native_reflection_worker.py +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.0}/hebbrix/_advice.py +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.0}/hebbrix/chat.py +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.0}/hebbrix/exceptions.py +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.0}/hebbrix/execution.py +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.0}/hebbrix/experience.py +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.0}/hebbrix/openai_reflection.py +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.0}/hebbrix/reflection_worker.py +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.0}/hebbrix/resources.py +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.0}/hebbrix/workflow.py +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.0}/hebbrix.egg-info/dependency_links.txt +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.0}/hebbrix.egg-info/entry_points.txt +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.0}/hebbrix.egg-info/requires.txt +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.0}/hebbrix.egg-info/top_level.txt +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.0}/setup.cfg +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.0}/tests/test_advanced_resources.py +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.0}/tests/test_advisor_integrity.py +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.0}/tests/test_answer_context.py +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.0}/tests/test_answer_decision.py +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.0}/tests/test_chat_answer_options.py +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.0}/tests/test_compact_search_default.py +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.0}/tests/test_evidence_loop_resource.py +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.0}/tests/test_evidence_safety_boundary.py +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.0}/tests/test_execution_permission.py +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.0}/tests/test_experience_request.py +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.0}/tests/test_experience_workflow.py +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.0}/tests/test_followup_helpers.py +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.0}/tests/test_memories_resource.py +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.0}/tests/test_openai_reflection.py +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.0}/tests/test_openapi_parity.py +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.0}/tests/test_outcome_advice_resource.py +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.0}/tests/test_procedural_resource.py +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.0}/tests/test_reflection_worker_cli.py +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.0}/tests/test_release_version.py +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.0}/tests/test_sync_client.py +0 -0
- {hebbrix-2.11.0 → hebbrix-2.12.0}/tests/test_workflow_route_contract.py +0 -0
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.12.0 — 2026-11-18 (values and value conflicts)
|
|
4
|
+
|
|
5
|
+
- Types: search rows (`MemoryRow`) gain `values` (server 1.4.45) and `value_conflicts` (server 1.4.46), and now also type `applies_to` and `entity_match`. `values` lists the codes a memory gives as values: a field's value (`customs_form='EXP-7'`) or a code a rule requires ("need customs form EXP-7"); a value never scopes a memory away from the task. `value_conflicts` lists `{"value", "query_value"}` objects (new type `ValueConflict`), set when the query or task names a different value of the same kind than one the memory requires. Both are optional: rows from older servers omit them, and unknown keys are kept as before.
|
|
6
|
+
- Behaviour change: `answer_context` renders `applies_to` as what the memory is about (`about: Acme, order 5531`) instead of `names …`, so a rule's required code no longer reads as a name; it renders `values` as `requires or gives: EXP-7` (a code listed in both appears once, as a value), and states each value conflict on its own line before the memory's text: `Conflicts with the task: task says EXP-9, memory requires EXP-7.` A row without `values` or `value_conflicts` renders exactly as in 2.11.0 apart from `about:` replacing `names`.
|
|
7
|
+
|
|
3
8
|
## 2.11.0 — 2026-11-13 (service failures, answer finality)
|
|
4
9
|
|
|
5
10
|
- `answer_status` `"unavailable"` (server 1.4.30): a service the evidence depends on failed for this request and nothing answers. `should_answer` declines it with action `retry`; never tell the user the fact is absent. Earlier versions declined it as `malformed_response`.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: hebbrix
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.12.0
|
|
4
4
|
Summary: Typed Python client for Hebbrix memory, retrieval, and outcome-learning APIs
|
|
5
5
|
Author-email: Hebbrix Team <support@hebbrix.com>
|
|
6
6
|
Maintainer-email: Hebbrix Team <support@hebbrix.com>
|
|
@@ -65,14 +65,14 @@ Dynamic: license-file
|
|
|
65
65
|
|
|
66
66
|
Typed Python client for Hebbrix memory, retrieval, and outcome-learning APIs.
|
|
67
67
|
|
|
68
|
-
The current stable package is **2.
|
|
68
|
+
The current stable package is **2.12.0**. Start with memory storage and search, or
|
|
69
69
|
the three-call outcome-learning workflow below. Advanced evidence and execution
|
|
70
70
|
permission transports are opt-in; installing the SDK never permits an action.
|
|
71
71
|
|
|
72
72
|
## Install
|
|
73
73
|
|
|
74
74
|
```bash
|
|
75
|
-
pip install hebbrix==2.
|
|
75
|
+
pip install hebbrix==2.12.0
|
|
76
76
|
```
|
|
77
77
|
|
|
78
78
|
Python 3.8+ is supported. `MemoryClient` is asynchronous. `SyncMemoryClient`
|
|
@@ -132,7 +132,8 @@ if not decision:
|
|
|
132
132
|
# decision.context holds the rows, never to answer from.
|
|
133
133
|
return my_reply_for(decision.action)
|
|
134
134
|
# The user's standing profile plus the rows you may answer from, each with its
|
|
135
|
-
# date, memory type, subject
|
|
135
|
+
# date, memory type, subject, what it is about, the values it requires or
|
|
136
|
+
# gives, any conflict with the task, and its support.
|
|
136
137
|
return await my_llm(question, context=answer_context(response, decision))
|
|
137
138
|
```
|
|
138
139
|
|
|
@@ -142,7 +143,12 @@ short" reach your model even when they did not rank for this message. It lists
|
|
|
142
143
|
each fact with its category, confidence and date, the topics to avoid, the
|
|
143
144
|
profile's `scope`, and says so when the profile is still being updated
|
|
144
145
|
(`projection.status: "pending"`) or could not be read, so a missing preference
|
|
145
|
-
is not taken as absent.
|
|
146
|
+
is not taken as absent. Each row says what the memory is about (`applies_to`:
|
|
147
|
+
`about: Acme, order 5531`) and the codes it requires or gives (`values`:
|
|
148
|
+
`requires or gives: EXP-7`). When the task names a different value of the same
|
|
149
|
+
kind than one the memory requires (`value_conflicts`), a line before the
|
|
150
|
+
memory's text says so: `Conflicts with the task: task says EXP-9, memory
|
|
151
|
+
requires EXP-7.` When the decision is not to answer it returns the
|
|
146
152
|
profile alone. `usable_memories(response)` returns just the rows. Pass
|
|
147
153
|
`history=True` for a question about the past, when superseded and historical
|
|
148
154
|
versions should count (it never overrides `unverified`, `no_relevant_memory`,
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
Typed Python client for Hebbrix memory, retrieval, and outcome-learning APIs.
|
|
4
4
|
|
|
5
|
-
The current stable package is **2.
|
|
5
|
+
The current stable package is **2.12.0**. Start with memory storage and search, or
|
|
6
6
|
the three-call outcome-learning workflow below. Advanced evidence and execution
|
|
7
7
|
permission transports are opt-in; installing the SDK never permits an action.
|
|
8
8
|
|
|
9
9
|
## Install
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
|
-
pip install hebbrix==2.
|
|
12
|
+
pip install hebbrix==2.12.0
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
Python 3.8+ is supported. `MemoryClient` is asynchronous. `SyncMemoryClient`
|
|
@@ -69,7 +69,8 @@ if not decision:
|
|
|
69
69
|
# decision.context holds the rows, never to answer from.
|
|
70
70
|
return my_reply_for(decision.action)
|
|
71
71
|
# The user's standing profile plus the rows you may answer from, each with its
|
|
72
|
-
# date, memory type, subject
|
|
72
|
+
# date, memory type, subject, what it is about, the values it requires or
|
|
73
|
+
# gives, any conflict with the task, and its support.
|
|
73
74
|
return await my_llm(question, context=answer_context(response, decision))
|
|
74
75
|
```
|
|
75
76
|
|
|
@@ -79,7 +80,12 @@ short" reach your model even when they did not rank for this message. It lists
|
|
|
79
80
|
each fact with its category, confidence and date, the topics to avoid, the
|
|
80
81
|
profile's `scope`, and says so when the profile is still being updated
|
|
81
82
|
(`projection.status: "pending"`) or could not be read, so a missing preference
|
|
82
|
-
is not taken as absent.
|
|
83
|
+
is not taken as absent. Each row says what the memory is about (`applies_to`:
|
|
84
|
+
`about: Acme, order 5531`) and the codes it requires or gives (`values`:
|
|
85
|
+
`requires or gives: EXP-7`). When the task names a different value of the same
|
|
86
|
+
kind than one the memory requires (`value_conflicts`), a line before the
|
|
87
|
+
memory's text says so: `Conflicts with the task: task says EXP-9, memory
|
|
88
|
+
requires EXP-7.` When the decision is not to answer it returns the
|
|
83
89
|
profile alone. `usable_memories(response)` returns just the rows. Pass
|
|
84
90
|
`history=True` for a question about the past, when superseded and historical
|
|
85
91
|
versions should count (it never overrides `unverified`, `no_relevant_memory`,
|
|
@@ -5,7 +5,7 @@ production OpenAPI and ``GET /v1/users/me/capabilities``. The experimental
|
|
|
5
5
|
World Model is intentionally absent from this release.
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
|
-
__version__ = "2.
|
|
8
|
+
__version__ = "2.12.0"
|
|
9
9
|
__author__ = "Hebbrix Team"
|
|
10
10
|
__license__ = "MIT"
|
|
11
11
|
|
|
@@ -38,6 +38,7 @@ from hebbrix.models import (
|
|
|
38
38
|
RevisionStatus,
|
|
39
39
|
ScopeIndexing,
|
|
40
40
|
SearchSafetyEnvelope,
|
|
41
|
+
ValueConflict,
|
|
41
42
|
)
|
|
42
43
|
from hebbrix.sync_client import SyncMemoryClient
|
|
43
44
|
|
|
@@ -64,6 +65,7 @@ __all__ = [
|
|
|
64
65
|
"MemoryStatus",
|
|
65
66
|
"RevisionStatus",
|
|
66
67
|
"ScopeIndexing",
|
|
68
|
+
"ValueConflict",
|
|
67
69
|
"answer_context",
|
|
68
70
|
"should_answer",
|
|
69
71
|
"usable_memories",
|
|
@@ -337,6 +337,56 @@ def _profile_lines(profile: Any) -> List[str]:
|
|
|
337
337
|
return lines
|
|
338
338
|
|
|
339
339
|
|
|
340
|
+
def _strings(value: Any) -> List[str]:
|
|
341
|
+
"""The non-empty strings of a list field; [] when an older API omits it."""
|
|
342
|
+
|
|
343
|
+
if not isinstance(value, list):
|
|
344
|
+
return []
|
|
345
|
+
return [item for item in value if isinstance(item, str) and item]
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
def _code(value: Any) -> Optional[str]:
|
|
349
|
+
if isinstance(value, str):
|
|
350
|
+
return value.strip() or None
|
|
351
|
+
if isinstance(value, (int, float)) and not isinstance(value, bool):
|
|
352
|
+
return str(value)
|
|
353
|
+
return None
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
def _conflict_lines(row: Mapping[str, Any]) -> List[str]:
|
|
357
|
+
"""One plain line per ``value_conflicts`` entry: the task names a different
|
|
358
|
+
value of the same kind than one the memory requires. A side the server did
|
|
359
|
+
not send is not a reason to drop the warning."""
|
|
360
|
+
|
|
361
|
+
conflicts = row.get("value_conflicts")
|
|
362
|
+
lines: List[str] = []
|
|
363
|
+
for conflict in conflicts if isinstance(conflicts, list) else []:
|
|
364
|
+
if not isinstance(conflict, Mapping):
|
|
365
|
+
continue
|
|
366
|
+
required = _code(conflict.get("value"))
|
|
367
|
+
asked = _code(conflict.get("query_value"))
|
|
368
|
+
if not required and not asked:
|
|
369
|
+
continue
|
|
370
|
+
line = (
|
|
371
|
+
f"Conflicts with the task: task says {asked or 'a different value'}, "
|
|
372
|
+
f"memory requires {required or 'a different value'}."
|
|
373
|
+
)
|
|
374
|
+
if line not in lines:
|
|
375
|
+
lines.append(line)
|
|
376
|
+
return lines
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
def _memory_lines(index: int, row: Mapping[str, Any]) -> List[str]:
|
|
380
|
+
"""A numbered memory: its details, any conflict with the task, its text."""
|
|
381
|
+
|
|
382
|
+
details = _memory_details(row)
|
|
383
|
+
return [
|
|
384
|
+
f"[{index}]" + (f" ({'; '.join(details)})" if details else ""),
|
|
385
|
+
*_conflict_lines(row),
|
|
386
|
+
str(row.get("content") or ""),
|
|
387
|
+
]
|
|
388
|
+
|
|
389
|
+
|
|
340
390
|
def _memory_details(row: Mapping[str, Any]) -> List[str]:
|
|
341
391
|
metadata = row.get("metadata") if isinstance(row.get("metadata"), Mapping) else {}
|
|
342
392
|
details = []
|
|
@@ -351,14 +401,15 @@ def _memory_details(row: Mapping[str, Any]) -> List[str]:
|
|
|
351
401
|
details.append(f"valid until {_day(row.get('valid_until'))}")
|
|
352
402
|
if row.get("subject"):
|
|
353
403
|
details.append(f"about {row['subject']}")
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
404
|
+
values = _strings(row.get("values"))
|
|
405
|
+
# A code the memory gives as a value says what it requires or gives, not
|
|
406
|
+
# what it is about: shown once, as a value.
|
|
407
|
+
given = {value.casefold() for value in values}
|
|
408
|
+
about = [n for n in _strings(row.get("applies_to")) if n.casefold() not in given]
|
|
409
|
+
if about:
|
|
410
|
+
details.append("about: " + ", ".join(about))
|
|
411
|
+
if values:
|
|
412
|
+
details.append("requires or gives: " + ", ".join(values))
|
|
362
413
|
if row.get("revision_status"):
|
|
363
414
|
details.append(str(row["revision_status"]))
|
|
364
415
|
grounding = row.get("grounding")
|
|
@@ -396,9 +447,13 @@ def answer_context(
|
|
|
396
447
|
it is still being projected from recent writes; an unavailable profile is
|
|
397
448
|
said to be unavailable, never left out as if empty. The memories section
|
|
398
449
|
lists only ``decision.memories``, numbered for citation, each with its
|
|
399
|
-
memory type, date,
|
|
400
|
-
|
|
401
|
-
|
|
450
|
+
memory type, date, whose fact it is, what it is about (``applies_to``:
|
|
451
|
+
"about: Acme, order 5531"), the values it requires or gives (``values``:
|
|
452
|
+
"requires or gives: EXP-7"), its revision status and its support. Each
|
|
453
|
+
``value_conflicts`` entry is stated on its own line before the memory's
|
|
454
|
+
text ("Conflicts with the task: task says EXP-9, memory requires EXP-7.").
|
|
455
|
+
When the decision is not to answer, only the profile is returned:
|
|
456
|
+
standing preferences still shape a reply such as
|
|
402
457
|
"I don't know that yet". For a Reason suggestion or plan (``context_only``)
|
|
403
458
|
the memories that should shape it are listed as context, marked as neither
|
|
404
459
|
established facts nor permission to act. Returns "" when there is nothing to
|
|
@@ -421,9 +476,7 @@ def answer_context(
|
|
|
421
476
|
)
|
|
422
477
|
lines = [heading]
|
|
423
478
|
for index, row in enumerate(decision.memories, start=1):
|
|
424
|
-
|
|
425
|
-
lines.append(f"[{index}]" + (f" ({'; '.join(details)})" if details else ""))
|
|
426
|
-
lines.append(str(row.get("content") or ""))
|
|
479
|
+
lines.extend(_memory_lines(index, row))
|
|
427
480
|
sections.append("\n".join(lines))
|
|
428
481
|
elif decision.reason == CONTEXT_ONLY and decision.context:
|
|
429
482
|
lines = [
|
|
@@ -431,8 +484,6 @@ def answer_context(
|
|
|
431
484
|
"facts, and never permission to act):"
|
|
432
485
|
]
|
|
433
486
|
for index, row in enumerate(decision.context, start=1):
|
|
434
|
-
|
|
435
|
-
lines.append(f"[{index}]" + (f" ({'; '.join(details)})" if details else ""))
|
|
436
|
-
lines.append(str(row.get("content") or ""))
|
|
487
|
+
lines.extend(_memory_lines(index, row))
|
|
437
488
|
sections.append("\n".join(lines))
|
|
438
489
|
return "\n\n".join(sections)
|
|
@@ -51,6 +51,17 @@ AnswerFinality = Literal["final", "provisional", "none"]
|
|
|
51
51
|
RevisionStatus = Literal["current", "superseded", "conflicting", "historical"]
|
|
52
52
|
|
|
53
53
|
|
|
54
|
+
class ValueConflict(TypedDict, total=False):
|
|
55
|
+
"""A value a memory requires where the query or task names a different
|
|
56
|
+
value of the same kind (server 1.4.46): the rule requires customs form
|
|
57
|
+
``EXP-7`` and the task says ``EXP-9``."""
|
|
58
|
+
|
|
59
|
+
# The value the memory requires.
|
|
60
|
+
value: str
|
|
61
|
+
# The value of the same kind the query or task names instead.
|
|
62
|
+
query_value: str
|
|
63
|
+
|
|
64
|
+
|
|
54
65
|
class MemoryRow(TypedDict, total=False):
|
|
55
66
|
"""One search row or Reason source, with its standing among the versions of
|
|
56
67
|
what it states. Decide what to do with a response in code:
|
|
@@ -75,6 +86,19 @@ class MemoryRow(TypedDict, total=False):
|
|
|
75
86
|
stated_at: Optional[str]
|
|
76
87
|
replaced_values: Optional[List[str]]
|
|
77
88
|
currency_basis: Optional[Literal["revision", "later_memory"]]
|
|
89
|
+
# What the memory is about: the names and record identifiers it names
|
|
90
|
+
# (customers, people, orders, tickets, campaigns).
|
|
91
|
+
applies_to: List[str]
|
|
92
|
+
# match, partial, mismatch, unscoped, or not_applicable when the query
|
|
93
|
+
# names no entity.
|
|
94
|
+
entity_match: Optional[str]
|
|
95
|
+
# Codes the memory gives as values (server 1.4.45): a field's value
|
|
96
|
+
# (customs_form='EXP-7') or a code a rule requires ("need customs form
|
|
97
|
+
# EXP-7"). A value never scopes a memory away from the task.
|
|
98
|
+
values: List[str]
|
|
99
|
+
# Each value the memory requires where the query or task names a different
|
|
100
|
+
# value of the same kind (server 1.4.46).
|
|
101
|
+
value_conflicts: List[ValueConflict]
|
|
78
102
|
|
|
79
103
|
|
|
80
104
|
class ScopeIndexing(TypedDict, total=False):
|
|
@@ -137,7 +161,8 @@ class SearchSafetyEnvelope(TypedDict, total=False):
|
|
|
137
161
|
degraded: bool
|
|
138
162
|
sdk_safety_reason: str
|
|
139
163
|
proof_context: Dict[str, Any]
|
|
140
|
-
# Entities the query names; each row carries applies_to/entity_match
|
|
164
|
+
# Entities the query names; each row carries applies_to/entity_match,
|
|
165
|
+
# and values/value_conflicts on servers that send them.
|
|
141
166
|
query_entities: List[str]
|
|
142
167
|
# Standing profile facts and preferences (search include_profile=True).
|
|
143
168
|
profile: Dict[str, Any]
|
|
@@ -1144,7 +1144,7 @@ class SyncMemoryClient:
|
|
|
1144
1144
|
self.source = source or os.getenv("HEBBRIX_SOURCE")
|
|
1145
1145
|
headers = {
|
|
1146
1146
|
"Content-Type": "application/json",
|
|
1147
|
-
"User-Agent": "hebbrix-python/2.
|
|
1147
|
+
"User-Agent": "hebbrix-python/2.12.0",
|
|
1148
1148
|
}
|
|
1149
1149
|
if api_key:
|
|
1150
1150
|
headers["Authorization"] = f"Bearer {api_key}"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: hebbrix
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.12.0
|
|
4
4
|
Summary: Typed Python client for Hebbrix memory, retrieval, and outcome-learning APIs
|
|
5
5
|
Author-email: Hebbrix Team <support@hebbrix.com>
|
|
6
6
|
Maintainer-email: Hebbrix Team <support@hebbrix.com>
|
|
@@ -65,14 +65,14 @@ Dynamic: license-file
|
|
|
65
65
|
|
|
66
66
|
Typed Python client for Hebbrix memory, retrieval, and outcome-learning APIs.
|
|
67
67
|
|
|
68
|
-
The current stable package is **2.
|
|
68
|
+
The current stable package is **2.12.0**. Start with memory storage and search, or
|
|
69
69
|
the three-call outcome-learning workflow below. Advanced evidence and execution
|
|
70
70
|
permission transports are opt-in; installing the SDK never permits an action.
|
|
71
71
|
|
|
72
72
|
## Install
|
|
73
73
|
|
|
74
74
|
```bash
|
|
75
|
-
pip install hebbrix==2.
|
|
75
|
+
pip install hebbrix==2.12.0
|
|
76
76
|
```
|
|
77
77
|
|
|
78
78
|
Python 3.8+ is supported. `MemoryClient` is asynchronous. `SyncMemoryClient`
|
|
@@ -132,7 +132,8 @@ if not decision:
|
|
|
132
132
|
# decision.context holds the rows, never to answer from.
|
|
133
133
|
return my_reply_for(decision.action)
|
|
134
134
|
# The user's standing profile plus the rows you may answer from, each with its
|
|
135
|
-
# date, memory type, subject
|
|
135
|
+
# date, memory type, subject, what it is about, the values it requires or
|
|
136
|
+
# gives, any conflict with the task, and its support.
|
|
136
137
|
return await my_llm(question, context=answer_context(response, decision))
|
|
137
138
|
```
|
|
138
139
|
|
|
@@ -142,7 +143,12 @@ short" reach your model even when they did not rank for this message. It lists
|
|
|
142
143
|
each fact with its category, confidence and date, the topics to avoid, the
|
|
143
144
|
profile's `scope`, and says so when the profile is still being updated
|
|
144
145
|
(`projection.status: "pending"`) or could not be read, so a missing preference
|
|
145
|
-
is not taken as absent.
|
|
146
|
+
is not taken as absent. Each row says what the memory is about (`applies_to`:
|
|
147
|
+
`about: Acme, order 5531`) and the codes it requires or gives (`values`:
|
|
148
|
+
`requires or gives: EXP-7`). When the task names a different value of the same
|
|
149
|
+
kind than one the memory requires (`value_conflicts`), a line before the
|
|
150
|
+
memory's text says so: `Conflicts with the task: task says EXP-9, memory
|
|
151
|
+
requires EXP-7.` When the decision is not to answer it returns the
|
|
146
152
|
profile alone. `usable_memories(response)` returns just the rows. Pass
|
|
147
153
|
`history=True` for a question about the past, when superseded and historical
|
|
148
154
|
versions should count (it never overrides `unverified`, `no_relevant_memory`,
|
|
@@ -30,6 +30,7 @@ tests/test_advanced_resources.py
|
|
|
30
30
|
tests/test_advisor_integrity.py
|
|
31
31
|
tests/test_answer_context.py
|
|
32
32
|
tests/test_answer_decision.py
|
|
33
|
+
tests/test_answer_values.py
|
|
33
34
|
tests/test_chat_answer_options.py
|
|
34
35
|
tests/test_compact_search_default.py
|
|
35
36
|
tests/test_customer_developer_experience.py
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
"""Search rows' values and value conflicts reach your model as what they are.
|
|
2
|
+
|
|
3
|
+
SDK 2.11.0 rendered ``applies_to`` as "names ...", so a rule's required code
|
|
4
|
+
read as a name ("names EXP-7"), and it never showed ``values`` (server 1.4.45)
|
|
5
|
+
or ``value_conflicts`` (server 1.4.46). ``applies_to`` is what a memory is
|
|
6
|
+
about; ``values`` is what it requires or gives; a value conflict means the task
|
|
7
|
+
names a different value of the same kind than one the memory requires.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from unittest.mock import AsyncMock, Mock
|
|
11
|
+
|
|
12
|
+
import pytest
|
|
13
|
+
|
|
14
|
+
import hebbrix
|
|
15
|
+
from hebbrix import MemoryRow, ValueConflict, answer_context, should_answer
|
|
16
|
+
from hebbrix.resources import SearchResource
|
|
17
|
+
from hebbrix.sync_client import SyncSearchResource
|
|
18
|
+
|
|
19
|
+
HEADING = "Memories to answer from (current, supported for this message):"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def row(memory_id, content, **fields):
|
|
23
|
+
return {
|
|
24
|
+
"memory_id": memory_id,
|
|
25
|
+
"id": memory_id,
|
|
26
|
+
"content": content,
|
|
27
|
+
"score": 0.9,
|
|
28
|
+
"low_confidence": False,
|
|
29
|
+
"is_current": True,
|
|
30
|
+
"revision_status": "current",
|
|
31
|
+
**fields,
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def search(rows, **fields):
|
|
36
|
+
return {
|
|
37
|
+
"query": "q",
|
|
38
|
+
"results": rows,
|
|
39
|
+
"total": len(rows),
|
|
40
|
+
"no_match": False,
|
|
41
|
+
"abstain_recommended": False,
|
|
42
|
+
"answer_status": "answerable",
|
|
43
|
+
"query_confidence": 0.9,
|
|
44
|
+
"grounding": {"status": "supported"},
|
|
45
|
+
"evidence_ids": [r["memory_id"] for r in rows],
|
|
46
|
+
"safety_contract_version": "search-safety-v1",
|
|
47
|
+
**fields,
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def rule(**fields):
|
|
52
|
+
return row(
|
|
53
|
+
"r1",
|
|
54
|
+
"Orders for Acme need customs form EXP-7.",
|
|
55
|
+
stated_at="2026-11-02T09:00:00Z",
|
|
56
|
+
metadata={"memory_type": "rule"},
|
|
57
|
+
grounding={"status": "supported", "support_basis": "verified_span"},
|
|
58
|
+
**fields,
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def lines(rows, **fields):
|
|
63
|
+
return answer_context(search(rows, **fields)).splitlines()
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
# Presence: the fields reach the caller untouched.
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
@pytest.mark.asyncio
|
|
70
|
+
async def test_both_clients_keep_values_and_conflicts_on_each_row():
|
|
71
|
+
conflict = {"value": "EXP-7", "query_value": "EXP-9", "kind": "customs_form"}
|
|
72
|
+
envelope = search(
|
|
73
|
+
[
|
|
74
|
+
rule(
|
|
75
|
+
applies_to=["Acme"],
|
|
76
|
+
entity_match="match",
|
|
77
|
+
values=["EXP-7"],
|
|
78
|
+
value_conflicts=[conflict],
|
|
79
|
+
)
|
|
80
|
+
]
|
|
81
|
+
)
|
|
82
|
+
sync, asynchronous = Mock(), Mock()
|
|
83
|
+
sync.post.return_value = dict(envelope)
|
|
84
|
+
asynchronous.post = AsyncMock(return_value=dict(envelope))
|
|
85
|
+
first = SyncSearchResource(sync).search_with_proof("q", user_id="u")
|
|
86
|
+
second = await SearchResource(asynchronous).search_with_proof("q", user_id="u")
|
|
87
|
+
for response in (first, second):
|
|
88
|
+
(kept,) = response["results"]
|
|
89
|
+
assert kept["applies_to"] == ["Acme"] and kept["entity_match"] == "match"
|
|
90
|
+
assert kept["values"] == ["EXP-7"]
|
|
91
|
+
# An unknown key on a conflict is kept, not stripped.
|
|
92
|
+
assert kept["value_conflicts"] == [conflict]
|
|
93
|
+
assert "sdk_safety_reason" not in response
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def test_row_types_name_the_entity_and_value_fields_and_require_none():
|
|
97
|
+
fields = MemoryRow.__annotations__
|
|
98
|
+
for name in ("applies_to", "entity_match", "values", "value_conflicts"):
|
|
99
|
+
assert name in fields
|
|
100
|
+
assert MemoryRow.__total__ is False
|
|
101
|
+
assert set(ValueConflict.__annotations__) == {"value", "query_value"}
|
|
102
|
+
assert ValueConflict.__total__ is False
|
|
103
|
+
assert "ValueConflict" in hebbrix.__all__
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
# Rendering.
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def test_applies_to_reads_as_what_the_memory_is_about():
|
|
110
|
+
text = lines([rule(applies_to=["Acme", "order 5531"])])
|
|
111
|
+
assert text == [
|
|
112
|
+
HEADING,
|
|
113
|
+
"[1] (rule; stated 2026-11-02; about: Acme, order 5531; current; "
|
|
114
|
+
"support verified_span)",
|
|
115
|
+
"Orders for Acme need customs form EXP-7.",
|
|
116
|
+
]
|
|
117
|
+
assert not any("names" in line for line in text)
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def test_a_required_code_reads_as_a_value_not_a_name():
|
|
121
|
+
text = lines([rule(applies_to=["Acme"], values=["EXP-7"])])
|
|
122
|
+
assert text == [
|
|
123
|
+
HEADING,
|
|
124
|
+
"[1] (rule; stated 2026-11-02; about: Acme; requires or gives: EXP-7; "
|
|
125
|
+
"current; support verified_span)",
|
|
126
|
+
"Orders for Acme need customs form EXP-7.",
|
|
127
|
+
]
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def test_a_code_listed_in_applies_to_and_values_reads_once_as_a_value():
|
|
131
|
+
text = lines([rule(applies_to=["Acme", "exp-7"], values=["EXP-7", "MGR-2"])])
|
|
132
|
+
assert text[1] == (
|
|
133
|
+
"[1] (rule; stated 2026-11-02; about: Acme; requires or gives: EXP-7, "
|
|
134
|
+
"MGR-2; current; support verified_span)"
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
def test_values_without_applies_to_still_render():
|
|
139
|
+
text = lines([rule(values=["EXP-7"])])
|
|
140
|
+
assert text[1] == (
|
|
141
|
+
"[1] (rule; stated 2026-11-02; requires or gives: EXP-7; current; "
|
|
142
|
+
"support verified_span)"
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def test_a_value_conflict_is_stated_before_the_memory_text():
|
|
147
|
+
conflicted = rule(
|
|
148
|
+
applies_to=["Acme"],
|
|
149
|
+
values=["EXP-7"],
|
|
150
|
+
value_conflicts=[{"value": "EXP-7", "query_value": "EXP-9"}],
|
|
151
|
+
)
|
|
152
|
+
assert lines([conflicted]) == [
|
|
153
|
+
HEADING,
|
|
154
|
+
"[1] (rule; stated 2026-11-02; about: Acme; requires or gives: EXP-7; "
|
|
155
|
+
"current; support verified_span)",
|
|
156
|
+
"Conflicts with the task: task says EXP-9, memory requires EXP-7.",
|
|
157
|
+
"Orders for Acme need customs form EXP-7.",
|
|
158
|
+
]
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
def test_each_conflict_gets_one_line_and_repeats_collapse():
|
|
162
|
+
conflicted = rule(
|
|
163
|
+
values=["EXP-7", "MGR-2"],
|
|
164
|
+
value_conflicts=[
|
|
165
|
+
{"value": "EXP-7", "query_value": "EXP-9"},
|
|
166
|
+
{"value": "MGR-2", "query_value": "MGR-5"},
|
|
167
|
+
{"value": "EXP-7", "query_value": "EXP-9"},
|
|
168
|
+
],
|
|
169
|
+
)
|
|
170
|
+
text = lines([conflicted])
|
|
171
|
+
assert text[2:] == [
|
|
172
|
+
"Conflicts with the task: task says EXP-9, memory requires EXP-7.",
|
|
173
|
+
"Conflicts with the task: task says MGR-5, memory requires MGR-2.",
|
|
174
|
+
"Orders for Acme need customs form EXP-7.",
|
|
175
|
+
]
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
def test_conflicts_are_listed_under_their_own_memory():
|
|
179
|
+
plain = row("m2", "Acme ships from Rotterdam.", applies_to=["Acme"])
|
|
180
|
+
conflicted = rule(value_conflicts=[{"value": "EXP-7", "query_value": "EXP-9"}])
|
|
181
|
+
text = lines([plain, conflicted])
|
|
182
|
+
assert text == [
|
|
183
|
+
HEADING,
|
|
184
|
+
"[1] (about: Acme; current)",
|
|
185
|
+
"Acme ships from Rotterdam.",
|
|
186
|
+
"[2] (rule; stated 2026-11-02; current; support verified_span)",
|
|
187
|
+
"Conflicts with the task: task says EXP-9, memory requires EXP-7.",
|
|
188
|
+
"Orders for Acme need customs form EXP-7.",
|
|
189
|
+
]
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
def test_a_conflict_missing_one_side_still_warns():
|
|
193
|
+
text = lines(
|
|
194
|
+
[
|
|
195
|
+
rule(
|
|
196
|
+
value_conflicts=[
|
|
197
|
+
{"value": "EXP-7"},
|
|
198
|
+
{"query_value": "EXP-9", "value": None},
|
|
199
|
+
{"value": 7, "query_value": 9},
|
|
200
|
+
]
|
|
201
|
+
)
|
|
202
|
+
]
|
|
203
|
+
)
|
|
204
|
+
assert text[2:5] == [
|
|
205
|
+
"Conflicts with the task: task says a different value, memory requires "
|
|
206
|
+
"EXP-7.",
|
|
207
|
+
"Conflicts with the task: task says EXP-9, memory requires a different "
|
|
208
|
+
"value.",
|
|
209
|
+
"Conflicts with the task: task says 9, memory requires 7.",
|
|
210
|
+
]
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
def test_a_suggestion_renders_values_and_conflicts_as_context():
|
|
214
|
+
page = {
|
|
215
|
+
"answer": None,
|
|
216
|
+
"sources": [
|
|
217
|
+
{
|
|
218
|
+
"memory_id": "r1",
|
|
219
|
+
"content": "Orders for Acme need customs form EXP-7.",
|
|
220
|
+
"applies_to": ["Acme"],
|
|
221
|
+
"values": ["EXP-7"],
|
|
222
|
+
"value_conflicts": [{"value": "EXP-7", "query_value": "EXP-9"}],
|
|
223
|
+
}
|
|
224
|
+
],
|
|
225
|
+
"decision_abstained": True,
|
|
226
|
+
"answer_status": "unverified",
|
|
227
|
+
"grounding": {"status": "supported", "answerability": "context_only"},
|
|
228
|
+
}
|
|
229
|
+
assert answer_context(page).splitlines()[1:] == [
|
|
230
|
+
"[1] (about: Acme; requires or gives: EXP-7)",
|
|
231
|
+
"Conflicts with the task: task says EXP-9, memory requires EXP-7.",
|
|
232
|
+
"Orders for Acme need customs form EXP-7.",
|
|
233
|
+
]
|
|
234
|
+
|
|
235
|
+
|
|
236
|
+
# Absence and malformed input: older servers and unknown shapes.
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
def test_rows_without_the_new_fields_render_as_before():
|
|
240
|
+
old = rule(applies_to=[])
|
|
241
|
+
assert lines([old]) == [
|
|
242
|
+
HEADING,
|
|
243
|
+
"[1] (rule; stated 2026-11-02; current; support verified_span)",
|
|
244
|
+
"Orders for Acme need customs form EXP-7.",
|
|
245
|
+
]
|
|
246
|
+
assert lines([old]) == lines([rule()])
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
@pytest.mark.parametrize(
|
|
250
|
+
"fields",
|
|
251
|
+
[
|
|
252
|
+
{"values": None, "value_conflicts": None, "applies_to": None},
|
|
253
|
+
{"values": "EXP-7", "value_conflicts": {"value": "EXP-7"}},
|
|
254
|
+
{"values": [None, "", 7, {"v": 1}], "applies_to": [None, "", 3]},
|
|
255
|
+
{"value_conflicts": [None, "EXP-7", [], {}, {"unknown": "EXP-9"}]},
|
|
256
|
+
{"value_conflicts": [{"value": " ", "query_value": True}]},
|
|
257
|
+
],
|
|
258
|
+
)
|
|
259
|
+
def test_malformed_fields_add_nothing(fields):
|
|
260
|
+
assert lines([rule(**fields)]) == lines([rule()])
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
def test_values_and_conflicts_do_not_change_the_decision():
|
|
264
|
+
plain = search([rule(applies_to=["Acme"])])
|
|
265
|
+
annotated = search(
|
|
266
|
+
[
|
|
267
|
+
rule(
|
|
268
|
+
applies_to=["Acme"],
|
|
269
|
+
values=["EXP-7"],
|
|
270
|
+
value_conflicts=[{"value": "EXP-7", "query_value": "EXP-9"}],
|
|
271
|
+
)
|
|
272
|
+
]
|
|
273
|
+
)
|
|
274
|
+
before, after = should_answer(plain), should_answer(annotated)
|
|
275
|
+
assert (before.answer, before.reason, before.action) == (
|
|
276
|
+
after.answer,
|
|
277
|
+
after.reason,
|
|
278
|
+
after.action,
|
|
279
|
+
)
|
|
280
|
+
assert [r["memory_id"] for r in after.memories] == ["r1"]
|
|
@@ -162,6 +162,6 @@ def test_package_docs_metadata_uses_canonical_host():
|
|
|
162
162
|
assert 'Documentation = "https://hebbrix.com/docs"' in text
|
|
163
163
|
assert "docs.hebbrix.com" not in text
|
|
164
164
|
readme = (root / "README.md").read_text()
|
|
165
|
-
assert "pip install hebbrix==2.
|
|
165
|
+
assert "pip install hebbrix==2.12.0" in readme
|
|
166
166
|
assert "three calls" in readme
|
|
167
167
|
assert "schema `" not in readme
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|