-
Notifications
You must be signed in to change notification settings - Fork 1
few-code-fixes #85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
few-code-fixes #85
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -89,6 +89,7 @@ def __init__( | |
| self._scoring = scoring_config or ScoringConfig() | ||
| self._estimator: TokenEstimator = estimator or CharDivFourEstimator() | ||
| self._hook: EventHook = hook or NoOpHook() | ||
| self._fact_counter: int = 0 | ||
|
|
||
| # ------------------------------------------------------------------ | ||
| # Properties | ||
|
|
@@ -290,7 +291,8 @@ def add_fact(self, key: str, value: str, metadata: dict[str, Any] | None = None) | |
| value: Fact value. | ||
| metadata: Optional metadata dict. | ||
| """ | ||
| fact_id = f"fact:{key}:{len(self._fact_store.all())}" | ||
| self._fact_counter += 1 | ||
| fact_id = f"fact:{key}:{self._fact_counter}" | ||
|
Comment on lines
+294
to
+295
|
||
| self._fact_store.put( | ||
| Fact( | ||
| fact_id=fact_id, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initializing
_fact_counterto 0 can reintroduce fact_id collisions when aContextManageris created with a pre-populatedfact_store(e.g., restored fromInMemoryFactStore.from_dict()or injected viaStoreBundle). In that case, subsequentadd_fact()calls can generate IDs that already exist and silently overwrite facts (sinceInMemoryFactStore.put()replaces byfact_id). Consider seeding_fact_counterfrom the existing store (e.g., max numeric suffix seen) or switching to a collision-resistant ID scheme (uuid/monotonic timestamp).