Translation cache key ignores service, model and system prompt, entries never expire
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
レポートでは、TranslateService::translate()がキャッシュキーを作成して保存する箇所として特定されています。まずこのメソッドとその周辺のキャッシュ使用箇所を読み、既存の翻訳テストでサービス、モデル、プロンプト、有効期限の各動作が網羅されているか確認してください。異なる設定を使う翻訳が互換性のないエントリーを再利用せず、キャッシュされたエントリーに有限の有効期間がある状態が完了の条件です。
索引モデルが issue の本文から書いたものです。
説明
Steps to reproduce
- Configure a distributed memory cache in
config.php(e.g. APCu or Redis) (e.g.'memcache.distributed' => '\OC\Memcache\Redis'), as recommended for production instances. - Configure two different translation services, or a single service whose model you can change in the settings.
- Translate the same text with the same source and target languages using the first service or model, then using the second one.
Expected behaviour
The second translation is actually performed by the second service or model, since different providers and models produce different translations of the same input.
Actual behaviour
The second translation is served from the cache entry written by the first one. The provider is never called again.
The cache key is built in TranslateService::translate() as:
$cacheKey = $sourceLanguageCode . '/' . $targetLanguageCode . '/' . md5($chunk);
The key contains neither the service, nor the model, nor the system prompt, so a cache entry written through one configuration is necessarily hit by any other configuration translating the same text between the same languages. Entries are also stored without a TTL ($cache->set($cacheKey, ...)), so once written, a translation is served forever, even after the underlying model or service configuration is changed or fixed.
This also means the cache silently loses most of its value as soon as an instance uses more than one translation service, since hits become essentially random across configurations.
Side observation: on instances without a distributed memory cache configured, the distributed cache falls back to a per-request backend, so the translation cache never hits at all and every translation is recomputed. If that fallback is considered acceptable for small instances it may be worth documenting; if not, the cache could use a different backend.
Suggested direction
Include at least the service id and the model in the cache key (and ideally the system prompt, which is part of the translation behaviour), and store entries with a finite TTL so that configuration or model changes eventually invalidate stale translations.
Reproduction on a live instance
Reproduced end-to-end on a live Nextcloud 35.0.3 instance with APCu as the distributed cache, using a local mock provider that echoes what it receives and logs every request. Two distinct translation services were configured, both pointing at the mock, and the same text was translated three times in a row:
| Call | Service | Model | Provider called? |
|---|---|---|---|
| 1 | A | model-aaa |
yes |
| 2 | A | model-bbb |
no — served from cache |
| 3 | B | model-ccc |
no — served from cache |
Only the first of the three translations reached the provider, although each used a different model or an entirely different service.
Assisted by Devin:SWE-2.1
- 主要言語
- PHP
- スター
- 78
- フォーク
- 42
- 平均マージ
- 2日 21時間
- マージ済み PR(30日)
- 5
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
nextcloud/integration_openai のほかの issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
nextcloud/integration_openai#477 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
nextcloud/integration_openai#471 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
Vllm rejecting requests that have empty tools list対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
nextcloud/integration_openai#448 · コメント 3 件 · リアクション 2 件 ·
メンテナーはふだん 1 日以内に返信
-
Chunked text processing silently drops the end of long texts対応中かも @nonofr91 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 35/100
nextcloud/integration_openai#478 ·
メンテナーはふだん 1 日以内に返信
-
Solve 2 transcription problems: Video input and big input対応中かも @danafon が 1 日前に担当しました。 オープンbug enhancement priority: high
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
nextcloud/integration_openai#472 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
nextcloud/integration_openai の issue をすべて見る
似ている issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 86/100
Automattic/static-site-importer#3462 ·
メンテナーはふだん 1 日以内に返信
-
Document lexicon.default.userconfig and lexicon.default.userconfig.enforced in config.sample.phpオープンenhancement feature: settings good first issue
難易度 1/5 1〜3時間 初心者へのやさしさ 88/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
roundcube/roundcubemail#10468 ·
メンテナーはふだん 1 日以内に返信
-
a11y
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
omeka/plugin-Contribution#84 ·