score timezone-aware memory timestamps instead of raising TypeError
メンテナーはふだん 1 日以内に返信
評価
調査の方向性
The failing subtraction is datetime.utcnow() - record.created_at in compute_composite_score() in lib/crewai/src/crewai/memory/types.py, reached from the recall paths in unified_memory.py and recall_flow.py. Reproduce by building a MemoryRecord with an aware UTC created_at and calling the score. Done means aware and naive inputs for the same instant give the same composite score. Open PR #9715 already targets this, so check it before starting.
索引モデルが issue の本文から書いたものです。
説明
Problem
compute_composite_score() in lib/crewai/src/crewai/memory/types.py computes the
recency term as
age_seconds = (datetime.utcnow() - record.created_at).total_seconds()
datetime.utcnow() is offset-naive, and MemoryRecord.created_at is only
naive by default (default_factory=datetime.utcnow). Nothing in the model
enforces that: a caller may pass datetime.now(timezone.utc), and the storage
backends hand back aware datetimes as well, because they persist
record.created_at.isoformat() (which appends the offset when the value was
aware) and parse it back with datetime.fromisoformat(...):
lib/crewai/src/crewai/memory/storage/lancedb_storage.py:290-296(_parse_dt,"Z"→"+00:00")lib/crewai/src/crewai/memory/storage/qdrant_edge_storage.py:223-228(_parse_dt)
Subtracting the two raises:
TypeError: can't subtract offset-naive and offset-aware datetimes
This helper is on every recall path — lib/crewai/src/crewai/memory/unified_memory.py:764
and lib/crewai/src/crewai/memory/recall_flow.py:140,169,371. In
recall_flow._do_search the call sits outside the try that wraps the storage
search, so the TypeError is not even logged and skipped: it aborts the whole
recall. Any user who creates a MemoryRecord with an aware UTC timestamp (the
form the datetime docs recommend) gets a working remember() and a
recall() that explodes.
Observed with the checkout at 6a5b80c (before-1.log):
created_at naive UTC -> composite=0.738110
created_at aware UTC -> TypeError: can't subtract offset-naive and offset-aware datetimes
EXPECTED: composite == 0.738110 (aware input scores like the same UTC instant)
ACTUAL: TypeError: can't subtract offset-naive and offset-aware datetimes
The same instant stored naively scores fine, so the failure is purely the
naive/aware mix and not the timestamp value.
I opened #9687 with a one-line fix and a regression test for this before reading the contribution flow; linking it here in case a maintainer wants to pick it up from the issue.
- 主要言語
- Python
- スター
- 61.2k
- フォーク
- 9.2k
- 平均マージ
- 1日 14時間
- マージ済み PR(30日)
- 180
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
crewAIInc/crewAI のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
[FEATURE] Add Straitly as a native OpenAI-compatible LLM provider対応中かも @HashimSyedUBC が 2 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
[BUG] Native OpenAI sync streaming with response_model returns an empty string and emits no completed event when the parse is missing対応中かも @basil-k-aji-dev が 2 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
[BUG] Native Azure provider ignores the seed setting対応中かも @basil-k-aji-dev が 2 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
crewAIInc/crewAI#9787 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
[BUG] LiteLLM path reports 0 cached and reasoning tokens in the usage summary対応中かも @basil-k-aji-dev が 2 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
crewAIInc/crewAI の issue をすべて見る
似ている issue
-
bug harness
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
mruangutai/harness#2687 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
modal-labs/modal-client#4158 ·
-
good first issue
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 半日 初心者へのやさしさ 72/100
The-Swarm-Corporation/swarms-rs#168 ·
メンテナーはふだん 1 日以内に返信
-
[BUG] SMTP listener now binds to EMAIL_PORT instead of 2525 since the gunicorn switch 5.0.3-ls373オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
linuxserver/docker-healthchecks#137 · コメント 1 件 ·